Definition
Cache-first strategy
Cache-first is a fetch-handling strategy: event.respondWith(caches.match(event.request).then((cached) => cached ?? fetch(event.request))). It serves cached content instantly and skips the network entirely when a match exists, making it ideal for versioned, immutable assets such as hashed JS/CSS bundles or app-shell icons that never change once deployed.
Because a cache hit never touches the network, cache-first should only be used for content that is safe to serve stale indefinitely — using it for an API endpoint that returns live data would show users outdated information with no way to detect it.
A common refinement adds a background refresh after serving from cache, which is effectively the stale-while-revalidate pattern rather than pure cache-first.
Cache-first assets are typically populated during the install event via precaching, so the first request after each deploy is a guaranteed cache hit rather than a race with the network.
The Workbox library provides this exact strategy out of the box as workbox.strategies.CacheFirst, including built-in cache expiration plugins for size and age limits.