如何清除 Firefox 中的 Service Worker 缓存?
How to clear a Service Worker cache in Firefox?
在 Chrome 中,可以从开发工具中清除 Service Worker 缓存。
我们如何在 Firefox 中实现这一点?
到目前为止我已经尝试过:
- 取消注册
about:serviceworkers
中的服务
- 清空
about:preferences#privacy
下的缓存
- 使用
Ctrl + F5
重新加载页面
但它仍然存在...
您可以在 Firefox Web 控制台中执行以下代码片段:
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");
});
有关此代码片段的更多信息,请查看 MDN 上的 Cache Web API page。
您无法在当前版本的 Firefox 中使用 Storage Inspector 清除 Service Worker 缓存。见 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.
如上所述,目前无法进行。但是删除缓存条目和缓存已经实现,应该很快就会推出 (https://bugzilla.mozilla.org/show_bug.cgi?id=1304297)。例如,它已经在 Firefox Developer Edition 中可用。
在 Firefox 的地址栏中键入此内容并注销您想要的服务工作者。
about:debugging#workers
编辑:在较新的版本中 #worker
锚点不起作用。您必须向下滚动到 Service Workers
部分。
在开发人员工具中,在“应用程序”选项卡下,您会找到服务工作者注册。单击取消注册。
在 Chrome 中,可以从开发工具中清除 Service Worker 缓存。
我们如何在 Firefox 中实现这一点?
到目前为止我已经尝试过:
- 取消注册
about:serviceworkers
中的服务
- 清空
about:preferences#privacy
下的缓存 - 使用
Ctrl + F5
重新加载页面
但它仍然存在...
您可以在 Firefox Web 控制台中执行以下代码片段:
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");
});
有关此代码片段的更多信息,请查看 MDN 上的 Cache Web API page。
您无法在当前版本的 Firefox 中使用 Storage Inspector 清除 Service Worker 缓存。见 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.
如上所述,目前无法进行。但是删除缓存条目和缓存已经实现,应该很快就会推出 (https://bugzilla.mozilla.org/show_bug.cgi?id=1304297)。例如,它已经在 Firefox Developer Edition 中可用。
在 Firefox 的地址栏中键入此内容并注销您想要的服务工作者。
about:debugging#workers
编辑:在较新的版本中 #worker
锚点不起作用。您必须向下滚动到 Service Workers
部分。
在开发人员工具中,在“应用程序”选项卡下,您会找到服务工作者注册。单击取消注册。