Created
October 16, 2017 13:05
-
-
Save zouhir/9d48fd4e4b7f6c58b1aba647aab9569b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Step1: | |
In app entry, comment `registerServiceWorker()` | |
#### Step2: | |
Your service worker file is supposed to be in: `https://yourdomain.com/service-worker.js` and this file is never | |
chacehd at yoyr users computer for offline use. | |
so after commenting the `registerServiceWorker` in your CRA app entry, the | |
CRA shoud not generate `service-worker.js` for you. What you should do is make one yourself and write inside | |
it the code you will use to unregsister your clients: | |
``` | |
// unregister SW | |
navigator.serviceWorker.getRegistrations() | |
.then((registrations) => { | |
const unregisterPromise = registrations.map((registration) => { | |
return registration.unregister(); | |
}) | |
}); | |
// cleare chaces | |
window.caches.keys() | |
.then((cacheNames) => { | |
return Promise.all(cacheNames.map((cacheName) => { | |
return window.caches.delete(cacheName); | |
})); | |
}); | |
``` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment