header Cache-Control: max-age=0意味着内容被认为是过期的(必须立即重新获取),这实际上与Cache-Control: no-cache是一样的。
当前回答
max-age When an intermediate cache is forced, by means of a max-age=0 directive, to revalidate its own cache entry, and the client has supplied its own validator in the request, the supplied validator might differ from the validator currently stored with the cache entry. In this case, the cache MAY use either validator in making its own request without affecting semantic transparency. However, the choice of validator might affect performance. The best approach is for the intermediate cache to use its own validator when making its request. If the server replies with 304 (Not Modified), then the cache can return its now validated copy to the client with a 200 (OK) response. If the server replies with a new entity and cache validator, however, the intermediate cache can compare the returned validator with the one provided in the client's request, using the strong comparison function. If the client's validator is equal to the origin server's, then the intermediate cache simply returns 304 (Not Modified). Otherwise, it returns the new entity with a 200 (OK) response. If a request includes the no-cache directive, it SHOULD NOT include min-fresh, max-stale, or max-age.
礼貌:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html # sec14.9.4
不要接受这个答案-我必须读它才能理解它的真正用法:)
其他回答
One thing that (surprisingly) hasn't been mentioned is that a request can explicitly indicate that it will accept stale data, using the max-stale directive. In that case, if the server responded with max-age=0, the cache would merely consider the response stale, and would be free to use it to satisfy the client's request [which asked for potentially-stale data]. By contrast, if the server sends no-cache that really does trump any request by the client (with max-stale) for stale data, as the cache MUST revalidate.
信息= 0
这相当于单击Refresh,这意味着给我最新的副本,除非我已经有了最新的副本。
no - cache
这是按住Shift同时点击刷新,这意味着,不管发生什么都要重做。
max-age When an intermediate cache is forced, by means of a max-age=0 directive, to revalidate its own cache entry, and the client has supplied its own validator in the request, the supplied validator might differ from the validator currently stored with the cache entry. In this case, the cache MAY use either validator in making its own request without affecting semantic transparency. However, the choice of validator might affect performance. The best approach is for the intermediate cache to use its own validator when making its request. If the server replies with 304 (Not Modified), then the cache can return its now validated copy to the client with a 200 (OK) response. If the server replies with a new entity and cache validator, however, the intermediate cache can compare the returned validator with the one provided in the client's request, using the strong comparison function. If the client's validator is equal to the origin server's, then the intermediate cache simply returns 304 (Not Modified). Otherwise, it returns the new entity with a 200 (OK) response. If a request includes the no-cache directive, it SHOULD NOT include min-fresh, max-stale, or max-age.
礼貌:http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html # sec14.9.4
不要接受这个答案-我必须读它才能理解它的真正用法:)
我不是缓存专家,但Mark Nottingham是。这里是他的缓存文档。他在参考资料部分也有很好的链接。
根据我对这些文档的阅读,它看起来像max-age=0可以允许缓存发送缓存的响应到“同一时间”的请求,其中“同一时间”意味着足够接近,它们看起来与缓存同步,但无缓存不会。
在我最近使用IE8和Firefox 3.5进行的测试中,两者似乎都符合rfc。但是,它们对源服务器的“友好性”有所不同。IE8对待无缓存响应的语义与max-age=0相同,必须重新验证。然而,Firefox 3.5似乎将无缓存等同于无存储,这在性能和带宽使用方面都很糟糕。
乌贼缓存,默认情况下,似乎从来没有存储任何无缓存头,就像Firefox。
我的建议是,对于您希望在每个请求上检查新鲜度的非敏感资源,设置public,max-age=0,但仍然允许缓存的性能和带宽优势。对于具有相同考虑的每个用户项目,使用private,max-age=0。
我会完全避免使用无缓存,因为它似乎已经被一些浏览器和流行缓存的功能等同为无存储。
此外,不要模仿Akamai和Limelight。虽然他们本质上把大量缓存数组作为主要业务,而且应该是专家,但他们实际上有既得利益,即从他们的网络下载更多的数据。谷歌可能也不是模拟的好选择。它们似乎根据资源随机使用max-age=0或no-cache。
推荐文章
- NGINX 499错误码的可能原因
- 什么是HTTP“主机”报头?
- 哪个HTTP状态代码表示“尚未准备好,稍后再试”?
- 清除JavaScript中的缓存
- 缓存一个HTTP 'Get'服务响应在AngularJS?
- 高速缓存线是如何工作的?
- 如何阻止恶意代码欺骗“Origin”报头来利用CORS?
- AngularJS禁用了开发机器上的部分缓存
- 自定义HttpClient请求头
- 为什么说“HTTP是无状态协议”?
- 过期和缓存控制头之间的区别是什么?
- 我需要HTTP GET请求的内容类型报头吗?
- 如何让Chrome允许混合内容?
- 正确的方式删除cookies服务器端
- REST DELETE真的是幂等的吗?