【发布时间】:2014-09-28 03:09:52
【问题描述】:
我正在使用 Angular js 视图和路由在 div 中加载不同的 HTML。 但是当我更改部分 html 并重新加载它时,仍然会显示缓存的版本。
根据我的研究,这不是由于 Angular js 模板缓存,
在加载 html 时,我尝试像 $templateCache.get('loadedPage.html') 那样获取缓存的 HTML,但结果未定义,因此缓存 html 的不是 angular js。
然后当我在 chrome 中看到时,我可以找到我的 html 缓存。我尝试了以下
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate"/>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta http-equiv="Cache-Control" content="no-store" />
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
但我仍然可以看到浏览器缓存 html。
还有其他方法吗?
【问题讨论】:
-
您尝试过的那些键和值应该设置在返回模板的 HTTP 响应的标头中。您必须配置您的网络服务器才能这样做。
标签: javascript jquery html angularjs caching