java - HTTP/1.1 完全禁用客户端缓存

标签 java browser-cache cache-control http-1.1 disable-caching

我有几个网站包含敏感数据,因此我想完全禁用客户端缓存。我在google上发现Http/1.1有3个实现:

  • 实现一:与其他设置“不存储”

    response.setHeader("Cache-Control", "no-store, no-cache, max-age=0, must-revalidate");
    
  • 实现2:设置“无存储、无缓存”

    response.setHeader("Cache-Control", "no-store, no-cache");
    
    // REASON is "no-cache" already cover this "max-age=0, must-revalidate"
    
  • 实现3:设置“no-store”:

    response.setHeader("Cache-Control", "no-store");
    
    // REASON is: "no-store": data is never stored 
    // on both client cache & intermediate caches
    

我找到了这个图表(来源自谷歌网站:Cache Control Policy Diagram)

Cache Control Policy Diagram

从这张图中,我的理解是实现 3 对于 HTTP/1.1 来说已经足够了

有什么意见吗?谢谢!

最佳答案

这取决于用户点击浏览器中的后退按钮时您希望发生的情况。

如果你不关心这个,请使用 no-store

如果你不想显示上一页,那么你也需要使用must-revalidate

关于java - HTTP/1.1 完全禁用客户端缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32082587/

相关文章:

java - 膨胀 View 时 WebCachedImageView 解析 XML 时出错

firefox - Firefox插件可删除一个域的缓存和cookie?

javascript - 浏览器后退按钮

javascript - 确定页面在 github 页面上已过时

google-chrome - 为什么浏览器仍然发送带有 max-age 的公共(public)缓存控制请求?

android - 我可以停止 HTTPResponseCache 在 Cache-Control header 方面表现得像共享缓存吗?

java - 请解释这个 put-if-absent 成语中的竞争条件

java - 频繁点击按钮时显示 Toast

css - 如何确保我网站的访问者看到重新设计的页面而不是旧的缓存页面和图形?

java - 是什么导致调用 View 的 OnDraw 方法以及何时