Definition
Network-first strategy
Network-first is a fetch-handling strategy: event.respondWith(fetch(event.request).then((res) => { cache.put(event.request, res.clone()); return res; }).catch(() => caches.match(event.request))). It prioritises up-to-date data and only serves a cached copy if the network request fails outright, making it the standard choice for API calls and frequently changing pages.
Because it waits for the network by default, network-first can feel slower than cache-first on poor connections — a common refinement adds a timeout (e.g. race the fetch against a 3-second timer) so the app falls back to cache sooner on very slow networks rather than only on outright failure.
Every successful network response should be cloned before both being returned to the page and stored in the cache, since a Response body can only be read once — forgetting response.clone() is one of the most common service worker bugs.
Network-first is a poor fit for large, rarely changing assets because it forces a network round trip even when the content is guaranteed unchanged; those cases are better served by cache-first or stale-while-revalidate.
Workbox implements this as workbox.strategies.NetworkFirst, with a configurable networkTimeoutSeconds option that automates the timeout-then-cache pattern described above.