【问题标题】:How to turn off caching of your website in chrome?如何在 chrome 中关闭网站缓存?
【发布时间】:2015-11-16 23:06:36
【问题描述】:

我试图防止在浏览器(chrome)上缓存机密文件,因此每次发出请求时,都从服务器获取文件,而不是从缓存中查看。我添加了以下 html 元标记,以指示 chrome 浏览器不缓存,但没有运气。

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

在检查网络流量时,缓存控制会根据请求设置为 max-age=0。并私下回复。

虽然我有这个在 IE 上工作。

【问题讨论】:

  • meta http-equiv 是个笑话,改用真正的 HTTP

标签: html google-chrome caching


【解决方案1】:

通常您更愿意在 .htacces 文件中根据文件类型(或任何其他模式)执行此操作,例如:

<IfModule mod_headers.c>
 <FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
    Header set Cache-Control "max-age=604800, public"
 </FilesMatch>

 <FilesMatch "\.(js|css)$">
    Header unset ETag
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
 </FilesMatch>
</IfModule>

用您选择的模式替换我的简单示例。此处还提供有关此主题的更多详细信息供参考:http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html

【讨论】:

    猜你喜欢
    • 2015-12-11
    • 2012-03-13
    • 2016-06-24
    • 2019-09-14
    • 2017-09-20
    • 2011-08-07
    • 1970-01-01
    • 1970-01-01
    • 2016-09-28
    相关资源
    最近更新 更多