DOM7011:此页面上的代码禁用了前后缓存

DOM7011: The code on this page disabled back and forward caching

我正在 IE 11 上测试我的 Angular 应用程序,不幸的是,它显示了一个银行页面,我在 polyfills 文件中取消了对必要行的评论,我可以看到登录页面,但是即使输入正确的凭据,响应也是 200 ok,我获得了登录所需的信息,但它不会重定向到主页,我可以在控制台中看到此消息 DOM7011: The code on this page disabled back and forward caching.这不是错误

我在 Whosebug 上阅读了很多内容,并且知道这个问题之前已经被问过,但是 none 的建议想法对我有用 该应用程序在所有浏览器中运行良好,例如(chrome、firefox、Edge、opera) 非常感谢任何建议

除了取消注释 polyfills.ts 中的所有导入行外,您是否使用 npm 安装了以下软件包?

npm install --save classlist.js 
npm install --save web-animations-js 

关于DOM7011警告,来自微软的official doc,返回导航缓存必须满足以下条件,您可以先检查您的应用页面是否满足这些条件:

  • Served using the HTTP: protocol (HTTPS pages are not cached for security reasons)
  • Page has no beforeunload event handlers defined
  • All load and pageshow events have completed
  • The page doesn't contain any of the following:
    • Pending indexedDB transactions
    • Open or active web socket connections
    • Running web workers
    • Microsoft ActiveX controls
  • The F12 Developer tools window isn't open

您还可以参考 调试 IE11 中的返回导航缓存。如果问题仍然存在,最好分享一个有助于重现问题的简单示例。

问题出在获取凭据并导航到主页时的登录组件中,但似乎它在 IE 中不起作用,因此解决方案是更换 this.router.navigate(['/']); 经过 this.router.navigate(['/home']);

第二个,IE不探索Date.parse,它在chrome和IE中给出不同的结果,所以我也替换它。

我也遇到了这个问题。我只是取消注释 polyfills.ts

中的以下部分
***************************************************************************************************
 * BROWSER POLYFILLS
 */

/** IE9, IE10, IE11, and Chrome <55 requires all of the following polyfills.
 *  This also includes Android Emulators with older versions of Chrome and Google Search/Googlebot
 */

import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';