Created by: jeffposnick
R: @gaearon @Timer
This adds in a "no-op" service-worker.js
at the root of the dev environment's web server.
It works around the issue of someone serving their dev and prod environments from the same port and ending up with a production service worker that controls their dev environment.
If a user finds themselves in that situation, then the next time the browser checks for an updated service worker, the "no-op" version will be installed instead, and immediately force any open pages to reload, so that they're once again talking directly to the dev server.
(The caveat here is that, as with all things service worker-y, this assumes that build/service-worker.js
was served using reasonable cache headers. I took a look at how the recommended serve
module responds to requests for the build/service-worker.js
, and it does appear to use a very short cache lifetime, so that's good!)
Fixes #2272 (closed)