Home > front end >  Is s-maxage supported by browsers?
Is s-maxage supported by browsers?

Time:05-27

I have a hard time finding out if s-maxage is supported by browsers, or by which versions of them.

s-maxage is primarily meant for shared caches, e.g. proxies or CDNs, but it seems to me that it also works in Chrome. For example, with a Next.js app that uses the Caching in Chrome

However, I can't find a definitive resource like a MDN document or anything that would document it. Anyone knows?

CodePudding user response:

You should not expect browsers to respect s-maxage.

As defined in the specification, s-maxage only applies to shared caches. 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.

  • Related