How to test service workers offline mode in localh

2019-07-07 07:43发布

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?

2条回答
Animai°情兽
2楼-- · 2019-07-07 08:29

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".enter image description here

查看更多
唯我独甜
3楼-- · 2019-07-07 08:38

Also, you could go to the Networks tab and perform the same action. Hope this helps :)

enter image description here

查看更多
登录 后发表回答