Skip to content

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

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

Closed
jhaddow opened this issue Dec 14, 2017 · 2 comments
Closed

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

jhaddow opened this issue Dec 14, 2017 · 2 comments

Comments

@jhaddow
Copy link

jhaddow commented Dec 14, 2017

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
Copy link
Author

jhaddow commented Dec 14, 2017

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
Copy link
Author

jhaddow commented Dec 15, 2017

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 jhaddow closed this as completed Dec 15, 2017
@lock lock bot locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant