禁止用户代理 max-age=0 标头
来自浏览器的 Cache-Control: max-age=0
标头导致我的 Rails 3.1 应用程序中带有 md5 缓存破坏程序的静态资源无法永久缓存,因为浏览器要求完全重新验证缓存并得到 304 未修改。我希望浏览器使用自己的缓存并且永远不会重新验证。我的服务器正在发送以下标头 max-age=31536000, public
。
The Cache-Control: max-age=0
header coming from the browser is causing the static assets with md5 cache buster in my rails 3.1 app to not get cached permanently because the browser is asking for a complete revalidation of the caches and getting a 304 not modified. I want that the browser use its own cache and never revalidate. My server is sending the following header max-age=31536000, public
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自用户代理的
Cache-Control: max-age=0
是用户代理请求重新验证缓存中任何内容的方式。您无法向客户端发送任何内容来阻止其发送此标头值。请参阅http://www.w3.org/Protocols/rfc2616/ rfc2616-sec14.html#sec14.9.3。您唯一能做的就是在应用程序前面配置缓存以忽略它,并将被视为过时(根据用户代理)的内容发送回用户代理,这应该是可能的。Cache-Control: max-age=0
from the user agent is the user agent's way of requesting that any content in the cache be revalidated. You can't send anything to the client to stop it sending this header value. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.3. The only thing you can do is configure the caches in front of your application to ignore it and send what would be considered stale (according to the user agent) content back to the user agent, which should be possible.