stale-while-revalidate
A caching strategy that answers immediately from the cache, even if out of date, while fetching a fresh copy in the background for next time.
In more detail
It balances speed and freshness for content like avatars or article lists where being one visit behind is fine. The same name is also a Cache-Control directive with similar meaning for the HTTP cache.
Related terms
- cache-first strategy — A caching strategy that answers from the cache when possible and only goes to the network, then caches the result, on a miss.
- network-first strategy — A caching strategy that tries the network first for fresh data and falls back to the cached copy only when the request fails.
- Cache-Control — The HTTP header that states the caching policy for a response, such as private, max-age=0 or no-store.
- revalidation — Refreshing cached data or pages so they show new content, either after a time limit or on demand.
- incremental static regeneration — Re-rendering a static page in the background after a set time or on demand, without rebuilding the whole site.
- SWR — A React data-fetching library from Vercel, named after the stale-while-revalidate strategy: show cached data at once, then refresh it in the background.
- single flight — Letting only one request fetch a missing value while other requests for the same key wait for its result.
- TTL — How long a stored item, such as a session, token or cache entry, stays valid before it expires.
- staleness — How out of date a copy of data is compared with the latest write.
Taught in
- Cache Storage API: Offline Strategies And Cache-First Patterns — Frontend Architecture & Web Platform
- Revalidation Strategies: revalidatePath & Cache Life — Next.js 15 & Modern App Router Architecture
- Cache Invalidation And The Three Hard Cases — Scalable System Design & Distributed Architecture