Debug a service worker in the Application panel
Update, bypass and unregister a service worker from the Chrome DevTools Application panel when a stale cache serves old files, and unregister from code.
A site keeps serving old files even after a deploy, and the cause is a service worker answering from its cache. The Application panel, under Service Workers, shows the worker and controls it.
Update on reload installs the new worker on every reload, so you do not wait for the old one to stop.
Bypass for network skips the worker and goes straight to the network.
Unregister removes the worker for this origin.
The same cleanup works from the console, which is easier to repeat:
const regs = await navigator.serviceWorker.getRegistrations();
console.log(regs.length);
await Promise.all(regs.map((r) => r.unregister()));1It prints how many registrations existed, then removes them. After a reload, the page is no longer controlled. The panel is described in the service worker debugging guide, and unregister is in the MDN reference.
Unregistering does not clear the caches the worker made. Open Storage in the Application panel and use Clear site data to remove them as well.