Reputation: 31171
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:
about:serviceworkers
about:preferences#privacy
Ctrl + F5
but it's still there...
Upvotes: 36
Views: 25712
Reputation: 4165
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.
Upvotes: 47
Reputation: 31471
In Firefox 101+, the process for unregistering all service workers:
for (let button of document.getElementsByClassName("qa-unregister-button")) { button.click(); }
Upvotes: 10
Reputation: 710
In developer tools, under the Application tab you will find service worker registrations. Click Unregister.
Upvotes: 2
Reputation: 171
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.
Upvotes: 1
Reputation: 12748
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.
Upvotes: 27