Help centre

Answer

How do you update a PWA’s service worker?

Short answer

Browsers automatically check your service-worker script for byte-level changes on every navigation (and roughly every 24 hours in the background). If it differs, the new version installs and waits until old tabs close before activating. Calling self.skipWaiting() in install and clients.claim() in activate makes the new version take over immediately instead of waiting.

By InstantPWA engineering·Reviewed July 25, 2026

Default (safe) update

Without skipWaiting(), users on an old tab keep using the old worker until they close every tab for that origin, avoiding a version mismatch mid-session.

Forced immediate update

skipWaiting() plus clients.claim() activates the new worker on next reload — commonly paired with a "New version available, refresh" toast so users are not surprised.

Cache versioning

Name your caches with a version string (e.g. app-v3) and delete old-versioned caches in the activate event so users are not stuck with stale assets.

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 difference between cache-first and network-first caching?
Cache-first checks the cache first and only goes to the network if there is no cached match — best for static assets like fonts and logos that rarely change. Network-first always tries the network first and falls back to the cache only if the request fails — best for content that should be as fresh as possible, like an API response, while still working offline.
What is the Background Sync API?
The Background Sync API lets a service worker register a task that the browser retries automatically once the device is back online, even if the user has closed the tab. It is commonly used so a form submission or message made while offline is not lost — it queues, then fires the moment connectivity returns.
What is Periodic Background Sync?
Periodic Background Sync lets an installed PWA periodically wake its service worker to refresh cached content — for example, prefetching news articles — even when the app is not open. It requires the periodic-background-sync permission, is only available on installed PWAs, and Chromium decides the actual interval based on site engagement, not the requested minimum.