[英]HTTP Cache Control max-age, must-revalidate
I have a couple of queries related to Cache-Control. 我有几个与Cache-Control相关的查询。
If I specify Cache-Control max-age=3600, must-revalidate
for a static html/js/images/css file, with Last Modified Header defined in HTTP header: 如果我指定Cache-Control
max-age=3600, must-revalidate
对静态html / js / images / css文件max-age=3600, must-revalidate
,并在HTTP标头中定义“ Last Modified Header”:
a) If the server includes this header: a)如果服务器包含此标头:
Cache-Control "max-age=3600, must-revalidate"
it is telling both client caches and proxy caches that once the content is stale (older than 3600 seconds) they must revalidate at the origin server before they can serve the content. 它告诉客户端缓存和代理缓存,一旦内容过时(早于3600秒),它们必须在原始服务器上重新验证才能提供内容。 This should be the default behavior of caching systems, but the
must-revalidate
directive makes this requirement unambiguous. 这应该是缓存系统的默认行为,但是
must-revalidate
指令使此要求明确。
b) The client should revalidate. b)客户应重新验证。 It might revalidate using the
If-Match
or If-None-Match
headers with an ETag, or it might use the If-Modified-Since
or If-Unmodified-Since
headers with a date. 它可能使用带有ETag的
If-Match
或If-None-Match
头来重新验证,或者使用带有日期的If-Modified-Since
或If-Unmodified-Since
头来重新验证。
a. 一种。 Look at the 'Stats' tab on this page and see what happens.
查看此页面上的“统计信息”标签,看看会发生什么。
b. b。 After expiration the browser will check at the server if the file is updated.
到期后,浏览器将在服务器上检查文件是否已更新。 If not, the server will respond with a
304 Not Modified
header and nothing is downloaded. 否则,服务器将以
304 Not Modified
标头响应,并且不会下载任何内容。
You can check this behaviour yourself by looking at the 'Net' panel in Firebug or similar tools. 您可以通过查看Firebug或类似工具中的“网络”面板来自己检查此行为。 Just re-enter the URL in the address bar and compare the number of HTTP requests with the number of requests when your cache is empty.
只需在地址栏中输入URL,然后将HTTP请求数与缓存为空时的请求数进行比较即可。
The given answers are incorrect, at least for web browsers in 2019. 给出的答案不正确,至少对于2019年的Web浏览器而言。
"After expiration the browser will check at the server if the file is updated" <- not true “到期后,浏览器将在服务器上检查文件是否已更新” <-不是
I have a static file served with "Cache-Control: public,must-revalidate,max-age=864000" and both Chrome and Firefox do a request every time (and get a 304 Not Modified back every time). 我有一个静态文件,其中包含“高速缓存控件:public,必须重新验证,最大使用期限= 864000”,Chrome和Firefox每次都发出请求(并每次返回304 Not Modified)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.