Skip to content

Why it matters

Stale-while-revalidate decouples user latency from origin latency, which is the central problem for any cached resource that can tolerate a slightly old copy.

The default cache behaviour couples the two: a stale entry means the user waits for the origin to respond. If the origin is slow (200ms), the user waits 200ms. If the origin is down, the user gets an error. SWR removes both couplings. The user waits a cache round-trip (single-digit milliseconds at the edge) and gets content immediately. The origin load, already low because most requests hit the cache, stays low because revalidations happen in the background, off the hot path. When the origin has a hiccup, users do not see it; they see the last good copy.

The practical effect is measurable. Pages served through SWR see their p95 latency dominated by the cache hit time, not the origin. TTFB becomes stable even when the origin is having a bad day. The origin's revalidation load becomes a small fraction of what it would be under default caching, because revalidations are single-shot per window instead of per request. For any resource whose freshness is not hyper-critical — a blog post, a product listing, a marketing page, an API response that changes on the order of minutes — SWR is the single highest-leverage cache directive available.