- From: dfabulich <notifications@github.com>
- Date: Tue, 06 Aug 2019 11:40:54 -0700
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 6 August 2019 18:41:16 UTC
I don't think the code is buggy. Try this sample. https://github.com/dfabulich/service-worker-refresh-sample
I think you've fallen into a common service worker trap. If you reload on `controllerchange` events and you've opened Chrome Dev Tools and checked the "Update on reload" box on the Application tab, it starts an infinite refresh loop.
Don't do this in the page:
```js
navigator.serviceWorker.addEventListener(`controllerchange`, function (event) {
window.location.reload();
}
```
do this instead
```js
var refreshing;
navigator.serviceWorker.addEventListener(`controllerchange`, function (event) {
if (refreshing) return;
refreshing = true;
window.location.reload();
}
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1238#issuecomment-518793545
Received on Tuesday, 6 August 2019 18:41:16 UTC