Service Worker
The service worker is the programmable network proxy at the core of every PWA. Running in its own thread, separate from the page, it intercepts network requests, serves responses from caches, and keeps working after the tab closes — the foundation of offline support, instant repeat loads, push, and background work.
These entries cover how the worker is installed and updated, how to cache deliberately, and the libraries and APIs built on top of it.
In this section
Section titled “In this section”Service worker lifecycleregister, install, activate, the waiting worker, skipWaiting, clients.claim, and updates.
Registration and scopenavigator.serviceWorker.register(), scope rules, Service-Worker-Allowed, and updateViaCache.
The update flow and skipWaitingHow the browser detects new versions, the waiting state, skipWaiting(), and clients.claim().
The fetch event and routingFetchEvent, event.respondWith(), routing by destination or URL, and passthrough.
Caching strategiesCache First, Network First, Stale-While-Revalidate, Network Only, Cache Only — when to use each.
The Cache APIcaches.open(), cache.add(), cache.match(), expiration, and opaque responses.
WorkboxRouting, precaching, expiration, background sync, and workbox-window for update UX.
Offline fallbackPre-caching a fallback page and serving it when both cache and network fail.
Debugging service workersChrome DevTools, Firefox, and Safari tooling for inspecting state, caches, and update flow.
← Back to the Reference overview.