大网数据广告活动
网站运营与故障问答

Default cache-control directives (and behaviour) when header returns only private

· 52CE 我爱测

I just checked the cache-control header returned by webmasters.stackexchange.com. The only directive present in the response is cache-control: private . In this case, what are the default values for other directives including max…

问题原文

原帖链接 · Kannan · CC BY-SA 4.0

I just checked the cache-control header returned by webmasters.stackexchange.com. The only directive present in the response is cache-control: private. In this case, what are the default values for other directives including max-age? Should a client re-validate (checking if the content is modified on the server) for every request?

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 4.0

Mozilla has a HTTP Caching FAQ that says:

[In this case] then the expiration calculation is essentially the algorithm described in RFC 2616 section 13.2.

...

The expiration time is computed as follows:

expirationTime = responseTime + freshnessLifetime - currentAge

where responseTime is the time at which the response was received according to the browser.

...

The freshness lifetime is calculated based on several headers. ... If [neither max-agenor Expires header are] present, then we look for a Last-Modified header. If this header is present, then the cache's freshness lifetime is equal to the value of the Date header minus the value of the Last-modified header divided by 10.

When I investigated this heuristic of Last-modified / 10 for Why is this response being cached?, I found that all major browsers appear to use this same heuristic.

According to Cache-Control - HTTP | MDN, clients must only revalidate if one of the following headers is present:

  • no-cache
  • max-age=0, must-revalidate

Since neither of those headers are present in this case, no revalidation needs to occur.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2021-06-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。