Does Cache-Control s-maxage header override Expires header for browser cache?

爷,独闯天下 提交于 2020-01-04 03:18:27

问题


I want to set a far future Expires headers to reduce requests made from individual browsers.

I'd also like to set Cache-Control: s-maxage=600 so that proxy caches (and CDNs) revalidate with the origin every 10 minutes for fresh content.

Will browsers honour the Expires header despite the existence of a Cache-Control header (which supposedly supersedes it) with a s-maxage directive?


回答1:


If a response includes both an Expires and a Cache-Control max-age directive, the max-age overrides the Expires header, even if the Expires header is more restrictive. This rule allows an origin server to provide, for a given response, a longer expiration time to an HTTP/1.1 cache than to an HTTP/1.0 cache.

Source: http://condor.depaul.edu/dmumaugh/readings/handouts/SE435/HTTP/node24.html




回答2:


If both are included then both will be checked, neither has precedence. Max-age does not supersede expires, it's additional.



来源:https://stackoverflow.com/questions/12479581/does-cache-control-s-maxage-header-override-expires-header-for-browser-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!