Stale-while-revalidate with Cache.match(): Serving Cached Responses While Refreshing Safely
The article explains how to use Cache.match() or an equivalent store to return the last cached response immediately while refreshing the resource in the background. Clients are notified only after the new copy is successfully written, so the UI never claims freshness before the cache has actually changed. A compare-and-set rule based on timestamps, ETags, or versions prevents an older network response from overwriting a newer cached entry. The author provides a minimal in-memory runtime and tests covering immediate cache returns, network fallback storage, and refusal to overwrite fresher data. The piece also notes limitations, including that it does not exercise browser-specific APIs or full HTTP validation semantics.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in