Pragma 没有缓存和 javascript
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6208715/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pragma no cache and javascript
提问by DD.
Does the pragma no-cache mean the browser will not cache javascript scripts?
pragma no-cache 是否意味着浏览器不会缓存 javascript 脚本?
e.g. Will the pragma no cache tag stop the browser from caching the jquery script?
例如,pragma no cache 标签会阻止浏览器缓存 jquery 脚本吗?
回答by BalusC
Actually, that depends on the browser used. For modern browsers you need to add Cache-Control
and Expires
headers as well.
实际上,这取决于使用的浏览器。对于现代浏览器,您还需要添加Cache-Control
和Expires
标题。
response.setHeader("Cache-Control", "no-cache,no-store,must-revalidate");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);