Created by: ro-savage
Adds invalidation of service workers based on by attempting to fetch
service-worker.js
and if its receives a 404, or if its the wrong content type (e.g. all not found urls are being redirected to index.html or serving a 404 page without a 404 code) it unregistered the current service worker and reloads the page.
This issues the issue where sites hosted on the same url:port
(e.g. localhost:5000
) are incorrectly displayingcreate-react-app
instead of the hosted page.
This was addressed in a more complex manner in #2438. However, this is a simplified version based on the feedback of @jeffposnick.
Note: I created a new PR/Branch because I believe #2438 addresses more cases, however it also adds complexity. This PR should fix most use cases when combined with #2426.