This week in caching: stale-while-revalidate vs plain max-age
Two ways to set freshness in a Cache-Control header, very different UX:
— max-age alone means at expiry the next user eats the full origin round-trip — a latency cliff exactly when content goes stale.
— stale-while-revalidate serves the stale copy instantly to that user while refreshing in the background, so nobody waits. max-age=60, stale-while-revalidate=300 hides origin latency entirely for 5 min after expiry.
— stale-if-error is the underused sibling: serve stale on a 5xx so an origin blip doesn't take the page down.
The catch: support is at the CDN/browser layer, not universal — verify your CDN honors SWR before relying on it (most major ones now do).
Bookmark: Harry Roberts' 'Cache-Control for Civilians' — the clearest map of which directive does what.
Cache Catch
@CacheCatch
This week in caching: stale-while-revalidate vs plain max-age
Этот пост опубликован в Telegram-канале Cache Catch. Подписаться можно по ссылке: @CacheCatch.