| > do you have any code or boilerplate I could plug in to achieve that? My implementation is at [0]. It basically fetches a list of files and hashes from GitHub, based on the commit in the X-GitHub-Commit response header (but you could just fetch master instead). You'd have to replace that github url at the top with [1], and update the two functions near the top. (If you're gonna fetch from master, also make the caching in getGitHubResponse less aggressive.) Also take a look at main.js and main.css in that commit, it contains code to notify the user. > it can check (not perfectly) if the new sw code matches the stored reference The problem is that currently, there is no way to get the new service worker code without a request. Even if the sw.js file is in cache, there is still a race condition between the cache responding and the new sw terminating the old one, and more often than not, the new sw wins. That's why I was talking in [2] about an alternative solution of adding a property somewhere that gives you the new sw code. What you can also do, and which I'm doing, is to fetch the sw.js file in the updatefound event of the page, and not of the old service worker. However, it's not strictly guaranteed that there is a (visible) page, for example, a third-origin website could embed yours in an iframe, triggering an update. [3] [0]: https://github.com/airbornos/airborn-server/commit/a740276b#... [1]: https://api.github.com/repos/dosyago-coder-0/dosycrypt-progr... [2]: https://lists.w3.org/Archives/Public/public-webapps/2017JulS..., near the bottom [3]: https://bugs.chromium.org/p/chromium/issues/detail?id=773307, haven't filed a spec issue for this yet because https://github.com/w3c/ServiceWorker/issues/1208 hasn't gotten any replies yet |