我希望浏览器只缓存图像而不缓存 html 文档,因为当我修改 .html
时,浏览器显示缓存的旧版本。
这是 中指定的 manifest.appcache
:
缓存 list
设置: 喜欢在线
网络:
*
回退:
缓存:
/img/cap.gif
/img/descarga(53).gif
/img/descarga(3).gif
/img/descarga(7).gif
我试过指定http header
缓存控制
:no-cache, max-age=0
Expires
:到等于日期标题的日期, future 1 分钟和过去 1 年的日期
Pragma
:无缓存
正如我在其他问题中看到的那样,我在 html head 中设置了标签:
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="星期二,1980 年 1 月 1 日 1:00:00 GMT"
meta http-equiv="pragma"content="no-cache"
但是这些都不起作用,浏览器会缓存图像和 html,还有另一种解决方案吗?谢谢。
最佳答案
将此放在 .htaccess 中此停止特定文件类型的缓存
<filesMatch "\.(jpeg,png)$">
FileETag None
<ifModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
</ifModule>
</filesMatch>
关于html - 如何停止缓存 html 但继续缓存其他资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25117413/