如何防止脚本从缓存加载[Angular]

问题描述 投票:0回答:1

我创建了一个Angular应用程序。我的应用程序从服务器加载脚本,但第一次运行后,照常从缓存中获取脚本。我当时使用的是现代浏览器,但我的技术负责人希望我也使其与旧版浏览器兼容。因此,我现在正在使用Internet Explorer 11。我添加了一些polyfill并运行了应用程序:

/*******************************************
 * BROWSER POLYFILLS
 */

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';

但是我们的要求是,应用程序应在每次页面加载时从服务器获取脚本。这是我的网络截图:enter image description here显然,我不能(或不应该)告诉我们的客户手动禁用其浏览器缓存。有什么方法可以防止我的代码仅针对IE 11或所有浏览器的这种情况?甚至可行吗?请帮助。

angular internet-explorer browser-cache
1个回答
0
投票

您可以使用命令ng build --outputHashing=bundles。它将创建带有哈希的已编译文件的唯一名称。它解决了缓存问题。

文档为here

© www.soinside.com 2019 - 2024. All rights reserved.