Definition
Service worker update cycle
Browsers check a registered service worker's script for updates on every navigation to a page in scope, and at least every 24 hours in the background, by re-fetching the script URL and comparing it byte-for-byte against the currently installed version. Any difference — even a single changed character or comment — triggers a fresh install/waiting/activate cycle for a new worker instance.
Because the comparison is byte-level, cache-busting the service worker script itself with a hashed filename is counterproductive: the browser needs a stable URL to compare against over time, so sw.js should generally not be renamed on every deploy the way app.[hash].js commonly is.
Serving the service worker script with a long Cache-Control max-age can delay update detection for up to that duration, since the browser's update check itself is subject to HTTP caching; most guidance recommends Cache-Control: no-cache or a short max-age specifically for the worker script.
You can force an immediate check from the page with registration.update(), useful right after a user action like re-focusing the tab, without waiting for the browser's own periodic schedule.
The full lifecycle — installing, waiting, activating, activated, redundant — is documented on MDN: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker/state.