Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify registering and unregistering service workers in README.md #3194

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions packages/react-scripts/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1581,16 +1581,17 @@ that your web app is reliably fast, even on a slow or unreliable network.
### Opting Out of Caching

If you would prefer not to enable service workers prior to your initial
production deployment, then remove the call to `serviceWorkerRegistration.register()`
production deployment, then remove the call to `registerServiceWorker();`
from [`src/index.js`](src/index.js).

If you had previously enabled service workers in your production deployment and
have decided that you would like to disable them for all your existing users,
you can swap out the call to `serviceWorkerRegistration.register()` in
[`src/index.js`](src/index.js) with a call to `serviceWorkerRegistration.unregister()`.
After the user visits a page that has `serviceWorkerRegistration.unregister()`,
the service worker will be uninstalled. Note that depending on how `/service-worker.js` is served,
it may take up to 24 hours for the cache to be invalidated.
you can swap out the call to `registerServiceWorker();` in [`src/index.js`](src/index.js)
with a call to `unregister();` - you will need to ensure you have imported
`unregister` by replacing `import registerServiceWorker from './registerServiceWorker';` with
`import { unregister } from './registerServiceWorker';`. After the user visits a page that has
`unregister();`, the service worker will be uninstalled. Note that depending on how
`/service-worker.js` is served, it may take up to 24 hours for the cache to be invalidated.

### Offline-First Considerations

Expand Down