Our application is a Polymer 2 single-page app that incorporates custom build steps to create versioned resource files using gulp-rev-all. Everything is functioning properly, but we are now looking to implement a secure way of refreshing the application. Currently, we are storing the latest git commit in a file served alongside the application, periodically checking for updates and notifying users of a new version available, prompting them to refresh the app by clicking a button.
The issue arises due to our use of a service worker with pre-cache as part of the default Polymer build setup. This presents a challenge because when we execute location.reload(), it retrieves content (such as index.html) from the service worker rather than the server.
Therefore, the question at hand is: How can we ensure that the service worker is invalidated, forcing a new refresh of both service-worker.js and index.html?