35

In Chrome it is possible to clear the Service Worker cache from the Dev Tools.

How can we achieve that in Firefox?

I've tried so far:

  • to unregister the service in about:serviceworkers
  • to empty the cache under about:preferences#privacy
  • to reload the page with Ctrl + F5

but it's still there...

1
  • Using the about:preferences#privacy screen will now clear service worker caches. You can clear specific site caches by using the "Manage Data..." button, or clear everything by using the "Clear Data..." button. Jun 5, 2018 at 20:11

5 Answers 5

44

Type this in the address bar of Firefox and deregister the service workers you want.

about:debugging

You can scroll down to Service Workers section or find using Ctrl+f or Cmd+f for that text.

2
  • 2
    to give a bit of update, the #workers anchor seems not working now. I entered about:debugging and scrolled down
    – Al-un
    Apr 26, 2020 at 7:48
  • If the list of Service Workers on the about:debugging page is long, you can do a Ctrl+f / Cmd+f search on that page in the typical fashion to search for the target site's domain name in the list. Feb 17, 2022 at 22:24
27

You can execute following code snippet in Firefox Web Console:

caches.keys().then(function (cachesNames) {
  console.log("Delete " + document.defaultView.location.origin + " caches");
  return Promise.all(cachesNames.map(function (cacheName) {
    return caches.delete(cacheName).then(function () {
      console.log("Cache with name " + cacheName + " is deleted");
    });
  }))
}).then(function () {
  console.log("All " + document.defaultView.location.origin + " caches are deleted");
});

For more information about this code snippet check Cache Web API page on MDN.

You can't clear Service Worker cache using Storage Inspector in current version of Firefox. See Storage Inspection documentation about currently available features. You can't use about:preferences#privacy or unregister Service Worker because Service Worker cache works independently of browser HTTP cache and managed only by your scripts. Relevant excerpt from Service Worker specification:

5.2 Understanding Cache Lifetimes The Cache instances are not part of the browser's HTTP cache. The Cache objects are exactly what authors have to manage themselves. The Cache objects do not get updated unless authors explicitly request them to be. The Cache objects do not expire unless authors delete the entries. The Cache objects do not disappear just because the service worker script is updated. That is, caches are not updated automatically. Updates must be manually managed. This implies that authors should version their caches by name and make sure to use the caches only from the version of the service worker that can safely operate on.

0
7

2022 Answer

In Firefox 101+, the process for unregistering all service workers:

  1. Navigate to about:debugging.
  2. Click all "Unregister Service Worker" buttons automatically by running this code in the dev console (F12):
for (let button of document.getElementsByClassName("qa-unregister-button")) { button.click(); }
2
  • 2023-06: for (let button of document.querySelectorAll("button[data-l10n-id='unregister-button']")) { button.click(); } Jun 23 at 22:24
  • 1
    This helped a lot.
    – Anutrix
    Sep 12 at 17:54
1

As mentioned above, it is not possible right now. But deleting Cache entries and Caches has been implemented and should roll out soone (https://bugzilla.mozilla.org/show_bug.cgi?id=1304297). And it is already available in Firefox Developer Edition, for example.

3
  • 1
    Now it's possible since v52
    – Supersharp
    Apr 5, 2017 at 14:11
  • 7
    @Supersharp how? Sep 8, 2017 at 2:53
  • 1
    As-of Firefox 75.0, you have to input about:debugging and scroll down to "Service Workers"
    – Al-un
    Apr 26, 2020 at 7:48
1

In developer tools, under the Application tab you will find service worker registrations. Click Unregister.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.