You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow runtimeCaching option without ejecting #3137
This is more of a feature request than a bug. But I love the fact CRA comes with a working SW. However, I'd like like to add another domain to the things which our automatically cached. But I'd really like to not have to eject.
Is there anyway to make the runtimeCaching option available through the package json? Or perhaps a way to get to the SW at runtime to configure it with additional domains to cache?
One way to solve is in the same manner as c-r-a deals with sass, e.g. does not create built-in solution, but creates easy-to-integrate outside solution
yarn build && yarn regenerate-sw
where yarn regenerate-sw will read contents of manifest.json, add more resources (what ever you need) and generate new service-worker.js
ah great; i'll look in to that (although slightly unclear right now how i'd "add more resources" or indeed change the runtimeCaching option for specific domains)
I'm looking into this too (have similar issue). Custom SW is just a tip of the iceberg. There are also UI problems, and need to choose proper strategy.
Activity
stereobooster commentedon Sep 18, 2017
One way to solve is in the same manner as
c-r-adeals withsass, e.g. does not create built-in solution, but creates easy-to-integrate outside solutionwhere
yarn regenerate-swwill read contents ofmanifest.json, add more resources (what ever you need) and generate newservice-worker.jsjliebrand commentedon Sep 18, 2017
ah great; i'll look in to that (although slightly unclear right now how i'd "add more resources" or indeed change the runtimeCaching option for specific domains)
stereobooster commentedon Sep 18, 2017
I'm looking into this too (have similar issue). Custom SW is just a tip of the iceberg. There are also UI problems, and need to choose proper strategy.
This can be a starting point https://github.com/codebusking/next-hnpwa-guide-kit/blob/master/generate-sw.js
UPD:
package.json
scripts/sw-precache-config.js
stereobooster commentedon Sep 18, 2017
@Swizec you might be interested in this issue too.
Also important bits:
service-worker.jswith http headers Conflict between service worker and CloudFront? #3082I'm using events to pass infor about service worker to UI
Other interesting thought: if you use redux you can refresh UI without user action (theoretically, like HMR #2304).
Timer commentedon Sep 26, 2018
Dupe of #4169