Skip to content
Browser internals·Advanced·Conceptual·1 min read

Walk through the service worker lifecycle from registration to controlling a page.

Short interview answer

The page calls navigator.serviceWorker.register(), which downloads and evaluates the worker script and fires its install event, typically used to pre-cache assets. Once install succeeds, the worker waits until no page is still controlled by a previous worker, then fires activate, typically used to clean up old caches. Only after activation does it begin controlling pages and intercepting their fetch events — already-open pages stay on the previous worker unless the new one calls clients.claim().

Key takeaway

Explain the underlying mental model clearly, then support it with a concrete example and its trade-offs.

← Back to Service workers, caching, and offline support

Related questions