This week in caching: stale-while-revalidate in production
Serve stale instantly, refresh in the background. What it bought:
— News homepage — s-maxage=60, stale-while-revalidate=600 meant users always got an instant cached page while the CDN refreshed behind them; perceived load stayed flat even as origin rebuild took 3s.
— Pricing API — SWR turned a 400ms origin fetch into a 5ms edge hit for 99% of callers; only one unlucky request per window paid the refresh cost.
— Blog — stale-if-error kept the site up serving cached HTML through a 6-minute origin outage; no maintenance page, users never noticed.
The magic: nobody waits on a cache miss anymore — the stale copy covers the gap.
Bookmark: Harry Roberts' write-up on Cache-Control directives — the SWR section is the clearest on the web.
Cache Catch
@CacheCatch
This week in caching: stale-while-revalidate in production
Этот пост опубликован в Telegram-канале Cache Catch. Подписаться можно по ссылке: @CacheCatch.