I am using React+Service Worker+offline-plugin to create a Service Workerwith persistent caching for the website.
I want to tell the user when a new version is stored in cach and suggest to refresh the page but I don't know how to reference the Service Workerand what event I should listen to (Service Workeris created automatically by npm "offline-plugin").
Standard flow today:
- Webmaster publish a site (V1)
- User visits the website
- He sees the website (V1) while Service Worker stores pages in persistent cache
- Webmaster publishes a new version (V2)
- User revisits the site seeing old version from persistent cache while web worker loading new version in the background (V2).
- When the user will refresh the page he will see website version 2
New flow should be:
- V2 loaded done in the background
- A popup message tels the user to refresh the page to get the new version.