最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to test service workers offline mode in localhost? - Stack Overflow

programmeradmin6浏览0评论

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?

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?

Share Improve this question asked Apr 3, 2017 at 22:42 Costa MichailidisCosta Michailidis 8,21818 gold badges84 silver badges137 bronze badges 2
  • Hmm.. discovered a 'work offline' option in firefox. Click preferences > Developer, and then all the way at the bottom is work offline. That worked.... okay, that didn't work. It worked for css changes, but not html files. Very strange. – Costa Michailidis Commented Apr 3, 2017 at 22:51
  • 1 The work offline option didn't work for me because localhost was still available with Apache. I turned off Apache and then i was able to test the offline version of the page without any problems. – Andres SK Commented Mar 29, 2018 at 17:27
Add a ment  | 

2 Answers 2

Reset to default 5

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".

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

发布评论

评论列表(0)

  1. 暂无评论