create-react-app icon indicating copy to clipboard operation
create-react-app copied to clipboard

Service worker does not cache files in build/static/js

Open jhaddow opened this issue 8 years ago • 2 comments

I've noticed that the service worker that ships with create-react-app does not cache the javascript files in /static/js of the build folder. Was this intentional? If so, what were the factors that influenced the decision to exclude these files from the cache.

jhaddow avatar Dec 14 '17 00:12 jhaddow

After reading the source code, it appears that this is not expected behavior. (See https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/config/webpack.config.prod.js#L325)

In our builds, the files in build/static/js are not cached in the service worker. Is this a bug?

jhaddow avatar Dec 14 '17 21:12 jhaddow

After further investigation, I found that the default max file size for sw-precache is 2.1 MB. Our main js bundle comes out to 2.4 MB before being gzipped, so sw-precache skips it. We will look into code splitting.

jhaddow avatar Dec 15 '17 01:12 jhaddow