Skip to content

Commit 2835105

Browse files
committed
More info for the READMEs.
1 parent bfed215 commit 2835105

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ Builds the app for production to the `build` folder.<br>
9393
It correctly bundles React in production mode and optimizes the build for the best performance.
9494

9595
The build is minified and the filenames include the hashes.<br>
96-
Your app is ready to be deployed!
96+
A [service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) using an [offline-first caching strategy](https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network) is automatically generated.<br>
97+
Your ([progressive web](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app)) app is ready to be deployed!
9798

9899
## User Guide
99100

packages/react-scripts/template/README.md

+33-11
Original file line numberDiff line numberDiff line change
@@ -1064,12 +1064,34 @@ located at [`public/manifest.json`](public/manifest.json), that you might want
10641064
to customize with metadata specific to your web application, such as its name
10651065
and branding colors.
10661066

1067+
If you would prefer not to enable service workers prior to your initial
1068+
production deployment, then remove the call to `serviceWorkerRegistration.register()`
1069+
from [`src/index.js`](src/index.js).
1070+
1071+
If you had previously enabled service workers in your production deployment and
1072+
have decided that you would like to disable them for all your existing users,
1073+
you can swap out the call to `serviceWorkerRegistration.register()` in
1074+
[`src/index.js`](src/index.js) with a call to `serviceWorkerRegistration.unregister()`.
1075+
After the user visits a page that has `serviceWorkerRegistration.unregister()`,
1076+
the service worker will be uninstalled.
1077+
10671078
### Offline-First Considerations
10681079

1069-
1. The service worker is only enabled in the production environment. It's
1070-
recommended that you do not enable an offline-first service worker in a
1071-
development environment, as it can lead to frustration when previously cached
1072-
assets are used and do not include the latest changes you've made locally.
1080+
1. Service workers [require HTTPS](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers#you_need_https),
1081+
although to facilitate local testing, that policy
1082+
[does not apply to `localhost`](http://stackoverflow.com/questions/34160509/options-for-testing-service-workers-via-http/34161385#34161385).
1083+
If your production web server does not support HTTPS, then the service worker
1084+
registration will fail, but the rest of your web app will remain functional.
1085+
1086+
1. Service workers are [not currently supported](https://jakearchibald.github.io/isserviceworkerready/)
1087+
in all web browsers. Service worker registration [won't be attempted](src/register-service-worker.js)
1088+
on browsers that lack support.
1089+
1090+
1. The service worker is only enabled in the [production environment](#Deployment),
1091+
e.g. the output of `npm run build`. It's recommended that you do not enable an
1092+
offline-first service worker in a development environment, as it can lead to
1093+
frustration when previously cached assets are used and do not include the latest
1094+
changes you've made locally.
10731095

10741096
1. If possible,configure your production environment to serve the generated
10751097
`service-worker.js` [with HTTP caching disabled](http://stackoverflow.com/questions/38843970/service-worker-javascript-update-frequency-every-24-hours).
@@ -1083,13 +1105,13 @@ will temporarily disable the service worker and retrieve all assets from the
10831105
network.
10841106

10851107
1. Users aren't always familiar with offline-first web apps. It can be useful to
1086-
let the user know when the service worker has finished populating your caches
1087-
(showing a "This web app works offline!" message) and also let them know when
1088-
the service worker has fetched the latest updates that will be available the
1089-
next time they load the page (showing a "New content is available; please
1090-
refresh." message). Showing this messages is currently left as an exercise to
1091-
the developer, but as a starting point, you can make use of the logic included
1092-
in [`src/register-service-worker.js`](src/register-service-worker.js), which
1108+
[let the user know](https://developers.google.com/web/fundamentals/instant-and-offline/offline-ux#inform_the_user_when_the_app_is_ready_for_offline_consumption)
1109+
when the service worker has finished populating your caches (showing a "This web
1110+
app works offline!" message) and also let them know when the service worker has
1111+
fetched the latest updates that will be available the next time they load the
1112+
page (showing a "New content is available; please refresh." message). Showing
1113+
this messages is currently left as an exercise to the developer, but as a
1114+
starting point, you can make use of the logic included in [`src/register-service-worker.js`](src/register-service-worker.js), which
10931115
demonstrates which service worker lifecycle events to listen for to detect each
10941116
scenario, and which as a default, just logs appropriate messages to the
10951117
JavaScript console.

0 commit comments

Comments
 (0)