如何卸载 Service Worker? [英] How do I uninstall a Service Worker?

查看:58
本文介绍了如何卸载 Service Worker?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我的根目录中删除 /serviceworker.js 后,Chrome 仍然运行我从 webroot 中删除的 service worker.如何从我的网站和 Chrome 中卸载 Service Worker,以便我可以重新登录我的网站?

After deleting /serviceworker.js from my root directory, Chrome still runs the service worker that I removed from my webroot. How do I uninstall the service worker from my website and Chrome so I can log back into my website?

我已将问题追溯到 Service Work 的缓存机制,我只想暂时删除,直到有时间调试为止.我使用的登录脚本重定向到 Google 的服务器,以便他们登录到他们的 Google 帐户.但是我从 login.php 页面得到的只是一个 ERR_FAILED 消息.

I've tracked the issue down to Service Work's cache mechanism and I just want to remove for now until I have time to debug it. The login script that I'm using redirects to Google's servers for them to login to their Google account. But all I get from the login.php page is an ERR_FAILED message.

推荐答案

以编程方式移除 Service Workers

您可以像这样以编程方式删除 Service Worker:

Removing Service Workers Programmatically

You can remove service workers programmatically like this:

navigator.serviceWorker.getRegistrations().then(function(registrations) {
 for(let registration of registrations) {
  registration.unregister()
} })

文档:getRegistrations取消注册

您还可以在 Chrome Devtools 的应用程序"选项卡下删除 Service Worker.

You can also remove service workers under the Application tab in Chrome Devtools.

这篇关于如何卸载 Service Worker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆