Definition
Stale-while-revalidate
Stale-while-revalidate is a fetch-handling strategy that serves whatever is already in Cache Storage without waiting on the network, then kicks off a background fetch to refresh that cache entry for the next request. It gives cache-first speed with eventual freshness, at the cost of occasionally showing content that is one request-cycle out of date.
A typical implementation: event.respondWith(caches.open("data-v1").then(async (cache) => { const cached = await cache.match(event.request); const fetchPromise = fetch(event.request).then((res) => { cache.put(event.request, res.clone()); return res; }); return cached ?? fetchPromise; }));, which returns the cached copy immediately if present but still lets fetchPromise update the cache in the background.
This pattern originates from the HTTP Cache-Control: stale-while-revalidate directive (see the IETF spec, RFC 5861) and service workers reimplement the same idea at the application layer with full control over cache lifetime.
It is well suited to content like user avatars, feed thumbnails or a dashboard summary where showing slightly stale data for one refresh cycle is an acceptable trade-off for instant load.
Workbox ships this as workbox.strategies.StaleWhileRevalidate, and it is one of the three strategies documented in Google's offline cookbook alongside cache-first and network-first: https://web.dev/articles/offline-cookbook.