Skip to content
jshacks.dev
Debugging

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.

1 min read
Summarize in AI

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:

JavaScript
const regs = await navigator.serviceWorker.getRegistrations();
console.log(regs.length);
await Promise.all(regs.map((r) => r.unregister()));
Text
1

It 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.

Also inBrowser
Share

More snippets

Debugging

Group related logs with console.group

Indent related console output under a label with console.group and console.groupEnd, so interleaved logs from one request stay readable in Node.js 24.

1 min read
APIs

Fetch JSON and handle HTTP errors

Fetch JSON in the browser or Node.js 24 and throw on 404 or 500 yourself, because fetch only rejects on network failure and does not check the status.

1 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.