-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Repro:
- Deploy the published app; load it on an iOS device so it starts working offline
- Make a change to
Index.razorand republish and redeploy - Visit on the same iOS device
- After giving it enough time to fetch the update in the background, navigate away to another page then navigate back
Expected: Should receive the update
Actual: Doesn't
This is because the update is meant to be triggered by the change to service-worker-assets.js (in that the content hash will have changed). However, at least as of Safari on iOS 13.3.1, the browser only checks for changes to service-worker.js and not to service-worker-assets.js. This is inconsistent with Chromium browsers which also check for changes to imported scripts. It's possible that iOS 13.4 might fix this, but it also might not.
In order to fix this, we need to change something in the publish flow so that we always make a modification to service-worker.js. For example, go back to the logic we had at an earlier stage whereby during publishing we always append // {GUID} to the file (using a random GUID).
Other issue
We should also change the service worker registration logic to look like this:
navigator.serviceWorker.register('service-worker.js', { updateViaCache: 'none' })This updateViaCache setting tells the browser to bypass its HTTP cache when fetching service-worker-assets.js, which is exactly what we want it to do.