No. Absolutely not. You should never force reload an application of any kind without the user asking for it. Instead, just show a non-obstructing notification saying something like βA new version is available. Reload to enable it.β.
It's actually easy. You can add an event listeners inside your service worker that listens for the install event. Whenever it fires, send a message via postmessage to your main thread and show a update info to your users.
When users presses ok send another message to the service worker back that triggers a "self.skipWaiting()" and afterwards a location.reload()
No. Absolutely not. You should never force reload an application of any kind without the user asking for it. Instead, just show a non-obstructing notification saying something like βA new version is available. Reload to enable it.β.
Fair enough. I guess I still need to know how to detect a new version of the app in order to show that message.
As it turned out I couldn't actually get my app to work offline in Chrome anyway π
It's actually easy. You can add an event listeners inside your service worker that listens for the install event. Whenever it fires, send a message via postmessage to your main thread and show a update info to your users.
When users presses ok send another message to the service worker back that triggers a "self.skipWaiting()" and afterwards a location.reload()
Thank you