[英]Disable of caching in browser [duplicate]
这个问题已经在这里有了答案:
我正在使用角度js视图和路由来在div中加载不同的HTML。 但是当我更改部分html并重新加载时,stil显示了缓存的版本。
根据我的reasearch,这不是由于角度js模板缓存引起的,导致HTML加载时,我试图获取像这样的$templateCache.get('loadedPage.html')
这样的缓存HTML,结果是未定义的,所以不是角度js正在缓存html。
然后当我在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。
还有其他方法吗?
最好在您的js中添加一些随机查询字符串或数据,以防止缓存在所有浏览器中,
<script type="text/javascript">
document.write('<script src="script.js?'+Math.random()+'"></script>');
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.