Re-add service worker
Because the service worker is in the root right now we are not cache busting it nor adding the right cache-control header. We should find a way to do this.
@molant The cache-control header is set to no-cache in the sonarwhal-worker. What's the "right" cache-control header value that it should be changed to? It doesn't seem right to me to set a max-age for the service worker since the content is mutable.
I think that if you move the scripts to /static/scripts the gulp task should take care of updating the file names and the html that points to it.
Here's a couple of pointers, I hope they'll be of help if/when you decide to reintroduce service workers again:
For webhint-worker.js:
- Should live in the root folder, enables full scope of the site.
- Don't set a hash in the url, it may cause issues (sw always updates if the file is modified anyways):
→ https://developers.google.com/web/fundamentals/primers/service-workers/lifecycle#avoid_changing_the_url_of_your_service_worker_script
- If usage of the
Cache-Controlheader is still desired (since the Chrome 68 changes, see link provided below) you will need to opt-in by settingupdateViaCacheto the preferred value. If that is the case,no-cacheshould suffice in making sure content is fresh, but yes the SW will incur a network request every navigation. → https://developers.google.com/web/updates/2018/06/fresher-sw
For sw-reg.js:
- Can be placed anywhere, just point the registration to
/webhint-worker.js.