html - 如何停止缓存 html 但继续缓存其他资源

标签 html caching cookies browser

我希望浏览器只缓存图像而不缓存 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/

相关文章:

Java缓存key->value,按标签分组(允许重置)

java - 运行 GWT 应用程序时出现 Unitcahche 异常

cookies - 防止经典 ASP 对 cookie 中的特殊字符进行编码

javascript - 如何附加 cookie 值

javascript - 从 Internet Explorer 读取 Cookie

html - 下拉框高度 : browser/OS compatibility issues

html - 如何模拟多个表格标题?

jquery - 多级下拉菜单 Bootstrap

html - CSS 后代选择器不更新元素

java - 当我们说一个特定的数据结构是缓存友好的时,这意味着什么?