Service Worker Update Checks
You'll learn when browsers automatically check for service worker updates and what triggers a fresh installation.
How Update Checks Work
Browsers don't blindly trust an old service worker forever. They periodically check if the service worker file has changed on your server. Think of it like a mail carrier who checks your mailbox on a schedule—even if you're not expecting anything, they still look to see if something new has arrived.
The browser checks for updates in these scenarios:
On Navigation
Every time a user navigates to a page within the service worker's scope, the browser performs an update check. It fetches the service worker file from the network and compares it byte-by-byte with the currently installed version.
Every 24 Hours
Even if the user stays on your site without navigating, the browser checks for updates at least once every 24 hours when the service worker is used. This prevents stale workers from living indefinitely.
On Manual Registration
If you call navigator.serviceWorker.register() again (like on page load), it triggers an update check immediately—though the browser may cache the result for a short time.
What Happens When Changes Are Detected
When the browser finds even a single byte difference in the service worker file, it treats this as a new version. The new worker enters the install phase but doesn't activate immediately—it waits until all pages using the old worker are closed (unless you use skipWaiting()).
Key Takeaway: Browsers automatically check for service worker updates on every navigation and at least once per day, comparing the file byte-by-byte to detect changes and trigger new installations.