我有几个网站包含敏感数据,因此我想完全禁用客户端缓存。我在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)
从这张图中,我的理解是实现 3 对于 HTTP/1.1 来说已经足够了
有什么意见吗?谢谢!
最佳答案
这取决于用户点击浏览器中的后退按钮时您希望发生的情况。
如果你不关心这个,请使用 no-store
如果你不想显示上一页,那么你也需要使用must-revalidate
关于java - HTTP/1.1 完全禁用客户端缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32082587/