2026-09-21 · 8 min read
- http
- caching
- reliability
Serving a slightly old response can reduce latency and preserve availability, but stale reuse is a product and security decision rather than a free performance win. stale-while-revalidate and stale-if-error define separate opportunities after normal freshness ends.
stale-while-revalidate permits eligible stale reuse while revalidation happens, whereas stale-if-error permits eligible stale reuse when an origin or forwarding attempt fails under supported conditions. Cache implementations can impose additional policy and limits.
Classify content by stale risk
Choose directives per response class. Public versioned assets, public catalog data, personalized account state, authorization decisions, and emergency notices have very different tolerance for old information.
- Never use shared stale responses for private user data.
- Keep safety and authorization state current.
- Set short initial windows during rollout.
- Document the maximum acceptable content age.
Model the full age timeline
Define freshness lifetime, stale-while-revalidate interval, stale-if-error interval, validators, and the time origin used by each cache. Capture Date and Age so operators can explain why a response was fresh, stale but permitted, or unusable.
Specify error classes that allow stale reuse and how request directives alter behavior. A timeout, DNS failure, 500 response, 404 response, and successful revalidation should not be treated as one undifferentiated event.
Coordinate every cache layer
Map browser caches, service workers, CDNs, reverse proxies, and application caches. Record which layer stores the response, changes Cache-Control, performs revalidation, collapses concurrent requests, and emits cache-status telemetry.
Use validators and request coalescing to avoid a revalidation stampede. Ensure purge, deployment, variant keys, authentication, localization, and emergency invalidation reach every layer that can serve stale data.
Test boundaries and recovery
Use Flashman's timestamp converter for age calculations, diff for field changes, URL tool for synthetic cache keys, units converter for duration budgets, and JSON formatter for sanitized cache traces.
Test each freshness and stale boundary, successful background revalidation, origin timeouts, selected error statuses, concurrent misses, disconnected clients, purges, variants, directives that forbid storage, clock errors, recovery, and telemetry accuracy.