使用“必须重新验证”的必要性有多大?在“缓存控制:无缓存,必须重新验证”中
我经常使用
Cache-Control: no-cache
or
Cache-Control: max-age=0
规范说 must-revalidate
适用于 max-stale
...(服务器问题 max-stale
?)
所以如果对于普通的Web服务器,Apache或带有Mongrels的Rails,那么我认为通常没有max-stale
,因此不需要must-revalidate
?
Often I use
Cache-Control: no-cache
or
Cache-Control: max-age=0
The spec says must-revalidate
is for max-stale
... (the server issue max-stale
?)
So if for normal web servers, Apache, or Rails with Mongrels, then I think usually there is no max-stale
, so must-revalidate
is not needed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
must-revalidate
应该由服务器指定,如果客户端获得过时的响应,这将是不正确(而不仅仅是次优)。这适用于您提到的所有具有max-stale
的请求。如果缓存暂时失去与源的连接,它也适用(在这种情况下,允许缓存返回带有Warning
标头的陈旧条目)。话虽这么说,我认为您是对的,在实践中特别不需要该指令;最常见的情况是源端希望让客户端缓存资源的副本(出于带宽节省目的),但始终在使用前对其进行验证,如:Cache-Control: private, max-age= 0,必须重新验证
must-revalidate
should be specified by servers where it would be incorrect (and not just suboptimal) for a client to get a stale response. This applies to all requests withmax-stale
as you mentioned. It also applies, if a cache temporarily loses connectivity to the origin (a cache is allowed to return a stale entry with aWarning
header in this case). That being said, I think you are right that this directive is not needed particularly in practice; it's seen most often in a situation where the origin wants to let a client cache a copy of the resource (for bandwidth conservation purposes) but always validate it before use, as in:Cache-Control: private, max-age=0, must-revalidate