Skip to content

Commit a9fb906

Browse files
committed
Add instructions for testing service-worker locally
1 parent a681e91 commit a9fb906

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/react-scripts/template/README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1087,12 +1087,20 @@ registration will fail, but the rest of your web app will remain functional.
10871087
in all web browsers. Service worker registration [won't be attempted](src/service-worker-registration.js)
10881088
on browsers that lack support.
10891089

1090-
1. The service worker is only enabled in the [production environment](#Deployment),
1090+
1. The service worker is only enabled in the [production environment](#deployment),
10911091
e.g. the output of `npm run build`. It's recommended that you do not enable an
10921092
offline-first service worker in a development environment, as it can lead to
10931093
frustration when previously cached assets are used and do not include the latest
10941094
changes you've made locally.
10951095

1096+
1. If you *need* to test your offline-first service worker locally, build
1097+
the application (using `npm run build`) and run a simple http server from your
1098+
build directory. After running the build script, `create-react-app` will give
1099+
instructions for one way to test your production build locally using
1100+
`pushstate-server` and the [deployment instructions](#deployment) have
1101+
instructions for using the python `SimpleHTTPServer`. *Be sure to always use an
1102+
incognito window to avoid complications with your browser cache.*
1103+
10961104
1. If possible,configure your production environment to serve the generated
10971105
`service-worker.js` [with HTTP caching disabled](http://stackoverflow.com/questions/38843970/service-worker-javascript-update-frequency-every-24-hours).
10981106
If that's not possible—[GitHub Pages](#github-pages), for instance, does not

0 commit comments

Comments
 (0)