简体   繁体   English

浏览器是否支持 s-maxage?

[英]Is s-maxage supported by browsers?

I have a hard time finding out if s-maxage is supported by browsers, or by which versions of them.我很难确定浏览器是否支持s-maxage ,或者它们的哪个版本。

s-maxage is primarily meant for shared caches, eg proxies or CDNs, but it seems to me that it also works in Chrome. s-maxage主要用于共享缓存,例如代理或 CDN,但在我看来它也适用于 Chrome。 For example, with a Next.js app that uses the recommended cache-control header like this:例如,对于使用推荐的缓存控制 header的 Next.js 应用程序,如下所示:

cache-control: public, s-maxage=10, stale-while-revalidate=59

I'm seeing this behavior in Chrome:我在 Chrome 中看到了这种行为:

在 Chrome 中缓存

However, I can't find a definitive resource like a MDN document or anything that would document it.但是,我找不到像 MDN 文档或任何可以记录它的权威资源。 Anyone knows?有谁知道?

You should not expect browsers to respect s-maxage .你不应该期望浏览器尊重s-maxage

As defined in the specification , s-maxage only applies to shared caches.如规范中所 定义s-maxage仅适用于共享缓存。 A browser cache is generally considered to be a private cache.浏览器缓存通常被认为是私有缓存。

I think what you're seeing is just the default caching that browsers do if you're not explicit about expiration.我认为你所看到的只是浏览器在你没有明确说明过期时所做的默认缓存。 Since none of your headers provide an explicit freshness lifetime , the cache is free to assign its own heuristic freshness .由于您的标头均未提供明确的新鲜度生存期,因此缓存可以自由分配其自己的启发式新鲜度 It's normal to see a cache hit even if you don't provide any expiration directives.即使您不提供任何过期指令,看到缓存命中也是正常的。

It is possible that the browser takes s-maxage into account when computing its heuristic freshness, but I certainly wouldn't rely on it.浏览器在计算其启发式新鲜度时可能会考虑s-maxage ,但我当然不会依赖它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 所有浏览器都支持 CSS 断字吗? - is CSS hyphenation supported by all browsers? 如何检测浏览器是否支持URL()构造函数? - How to detect if URL() constructor is supported by browsers? 在不支持的浏览器中替代 IndexedDB? Safari/iOS Saf-Chrome - Alternative to IndexedDB in not supported browsers? Safari/iOS Saf-Chrome 现代浏览器仍支持自签名证书吗? - Are self-signed certificates still supported in modern browsers? 如果不支持用户的浏览器,我可以呈现警告消息吗? - Can I render warning message if user's browser is not supported? Ajax在下拉列表中无法在IE8中工作,但在其他浏览器中工作正常 - Ajax not working in IE8 on dropdown but it's working fine in other browsers 浏览器是否没有正确遵循 HTTP 规范的缓存控制? - Do browsers not follow the HTTP spec's Cache-Control correctly? 为什么 Safari 的默认字体跟踪/字母间距与其他浏览器不同? - Why is Safari’s default font tracking/letter-spacing different than other browsers? 在webkit浏览器中,v3谷歌地图不尊重容器的border-radius。 有人有解决方法吗? - In webkit browsers, v3 google maps do not respect container's border-radius. Anyone have a workaround? 无法使用Express 3.0在Node.js中设置cookie'expires'或'maxAge' - Can't set cookie 'expires' or 'maxAge' in Node.js using Express 3.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM