Help centre

Answer

How do you debug a service worker?

Short answer

Open Chrome DevTools → Application tab → Service Workers panel. It shows the registered worker’s status (activated, waiting, redundant), lets you check "Update on reload" to force a fresh install every load, simulate offline mode, and unregister a stuck worker. Console logs from inside the worker appear in the main console when you select the worker’s context from the dropdown.

By InstantPWA engineering·Reviewed July 25, 2026

Common debugging steps

Check "Update on reload" during development so every refresh installs and activates the latest worker instead of serving a stale cached version.

Inspecting cache contents

Application → Cache Storage lists every named cache and its stored request/response pairs, useful for verifying what actually got precached.

Simulating offline

The Network tab’s throttling dropdown includes "Offline", which is the fastest way to verify your offline fallback actually works.

Related
What is the service worker lifecycle?
A service worker moves through four stages: install (fired once when the browser first downloads a new or changed worker), waiting (if an old version still controls open tabs), activate (once it takes control, typically after all old tabs close or skipWaiting() is called) and idle, where the browser terminates it between events to save memory.
Do PWAs work offline?
PWAs can work offline, but only for content their service worker has explicitly cached. Registering a service worker does not automatically make a site offline-capable — you decide what to cache (app shell, API responses, images) and what strategy to use (cache-first, network-first, stale-while-revalidate).
What is the Cache Storage API?
The Cache Storage API is a browser-native key-value store for Request/Response object pairs, accessible from both a service worker and the page via the global caches object. It is the primary mechanism PWAs use to store network responses — HTML, CSS, JS, images, API JSON — so they can be served offline or instantly on repeat visits.
IndexedDB vs localStorage: which should a PWA use?
localStorage is a simple synchronous key-value store limited to strings and roughly 5-10MB, and it is not accessible from inside a service worker. IndexedDB is an asynchronous, transactional database that can store structured objects, blobs and much larger amounts of data, and it is accessible from both the page and the service worker — making it the right choice for most PWA data storage.
Can a PWA lock screen orientation?
Yes. The Screen Orientation API’s screen.orientation.lock("landscape") method (or "portrait") can force a specific orientation, but on most browsers it only works while the page is in fullscreen mode via the Fullscreen API. An installed PWA can also declare a preferred orientation directly in its manifest with the "orientation" field, which locks orientation for the whole standalone app.