Proof of Concept: Add cache busting and auto-reloading to service workers #2563
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an attempt to address issue #2554 SWI3. Issues with service worker cache invalidation.
It also addresses SWI1 & SWI2 by auto reloading updated/different pages without user interaction.
To avoid confusion to the user, while the page is checking if the service worker is changed / exists, it displays a blank page.
Using the technique we damage a few of the advantages of PWA in return for 'easy of use' for developers and end users.
By default with PWA/SW, we can load the page instantly with the old/cached content. Using this technique, we must wait for a response from the server before showing the page. (Still works offline)
If we we find the page has changed, we do a force reload which means we've already hit the server once and waited for a response, and we then have to do the whole thing over again. If we'd just not used service workers we would have loaded the page faster.
This is just a POC. It is not a solid way to solve issues due to the issues above. Hopefully it might inspire some other ideas about how we could invalidate SWs and alternative ways to update the app without asking the user to refresh.