If you have a local directory full of static files (HTML, JS, CSS, etc.), sw-precache
can be configured to automatically precache all of them (or some subset of them) based on the patterns you pass in to the staticFileGlobs
option. The previously precached entries in users' browsers will be kept up to date as you make local changes, regenerate your service-worker.js
, and redeploy.
In general, there aren't hard upper limits on the maximum amount of data that can be stored using the Cache Storage API. It depends on the amount of space that's currently free (potentially along with other heuristics).
You should be considerate when determining what files get precached and ensure that they're actually files that your users are likely to find useful. For example, if the very first time a user visits your (hypothetical) documentation site, they end up downloading and storing thousands of individual HTML documents, that's a waste of bandwidth for both your servers and your users—in addition to taking up space on users' devices.
If you have a large trove of resources that are optional or not likely to be needed by all visitors, that using a precaching strategy for the crucial resources, along with a runtime caching strategy for the optional resources, is your best bet. You can combine the runtime caching strategy with a maximum cache size or maximum age, and the underlying sw-toolbox
library will take care of deleting old entries for you.