如何在本地主机中测试服务工作者离线模式? [英] How to test service workers offline mode in localhost?

查看:32
本文介绍了如何在本地主机中测试服务工作者离线模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在本地以离线模式测试 Service Worker?我的意思是,本地主机不需要互联网访问,所以它只是不断获取所有文件.我可以在 Firefox 或 Chrome 中以某种方式进行离线模拟,以便查看缓存失败或其他问题时会发生什么吗?

How can I test service workers in offline mode locally? I mean, localhost doesn't need internet access so it just keeps fetching all the files. Can I simulate offline in Firefox or Chrome somehow so I can see what happens when caching fails, or other things go wrong?

推荐答案

在 Chrome 中,您可以在 DevTools 的 Application 选项卡中模拟离线,>Service Workers 面板.您会看到一个复选框,上面写着 离线".

In Chrome, you can simulate being offline in the DevTools' Application tab, inside the Service Workers panel. You will see there a checkbox that says "Offline".

这篇关于如何在本地主机中测试服务工作者离线模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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