Unchanged service worker is re-installing and re-caching

不打扰是莪最后的温柔 提交于 2019-11-30 16:39:28

So the very first time the service worker is installed, I see 3 cache hits, for the 3 files I'm loading. If I close and re-open, I get 6, then 9, etc. In any case, simply refreshing the page shows the original 3 cache hits as expected.

Most probably is that you are seeing previous logs. To verify, you can show the timeline of every log.

  1. Go to dev tools settings F1 inside console or click on the icon (img1)
  2. Check the option Show timestamps (img2).
  3. Or simple add a console.log(new Date()); inside your fetch event handler.

Img1


Img2



Now you will be able to identify logs that are from previous requests. Your sw is not making extra request, just the console is keeping old logs.


To fix it, do right click inside the console and click on clear console history.

Hope this help.

It should not be there because the install event is called only once.I think the issue is in your chrome browser force update service worker is checked.Open developer console on chrome -> go to application tab -> service worker and uncheck update on reload.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!