Testing our cache
Run your app locally quickly with yarn start
to check for any obvious errors (typos and such), and if all looks good, fire up yarn deploy
.
Open your live application and the Chrome DevTools. Turn off Update on reload
under Application
| Service Workers
, refresh once, and then go to the Network
tab. You should see something like the following:
Note
If this doesn't work, try Unregistering any service workers under Application
| Service Workers
, and then reload twice.
The key point is (from service worker) beside our JavaScript files. Our static assets are being served up by our service worker cache, and if you scroll to the top of the network tab, you'll see this:
The document itself is being served from the service worker, which means we can run our app under any network condition, even offline; let's try it. Click on the Offline
checkbox at the top of the Network
tab, and click on reload.
If all goes well, there should be no difference between our application's load time, even...