我正在 AngularJs 中构建一个 Office Web 应用程序,并且我的视图正在被缓存,我正在尝试研究如何防止我的 AngularJS 视图被缓存。
更改 Index.html 文件,因为 *.js 反映在选项卡窗格中,但视图中的任何更改都不会。以下是一些没有奏效的事情:
将这些添加到 index.html 的标题中:
<meta http-equiv="cache-control" content="no-store">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
将此添加到 application.js:
app.run(function ($rootScope, $templateCache) {
$templateCache.removeAll();
$rootScope.$on('$viewContentLoaded', function () {
$templateCache.removeAll();
});
});
将此添加到 web.config:
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
唯一有效的是重命名视图。
单独使用时,缓存不会出现在 Chrome、Firefox 甚至 IE 中。