vite-pwa / docs

Documentation: PWA integrations for Vite and the ecosystem
https://vite-pwa-org.netlify.app/
MIT License
196 stars 42 forks source link

Doc around caching strategy is confusing. #106

Open sgpinkus opened 8 months ago

sgpinkus commented 8 months ago

Docs state:

You can also configure how to control the network requests interception for any of your application resources. You can find more information on Workbox - Caching Strategies. -- https://vite-pwa-org.netlify.app/guide/service-worker-precache.html

The linked workbox doc talks about cache-only, network-only, and cache-first-then-network, network-first-then-cache, showing you how to implement this if your implementing the caching yourself (and hence the entire service worker yourself). That's not really helpful - I'm using vite-pwa to avoid having to write the SW and caching implementation myself! Neither docs hint at a workbox or vite-pwa option to configure any one of the strategies.

AFAICT vite-pwa just generates a service worker with a cache-only strategy and there is no option to select a strategy. Is that the case? If so, saying "You can also configure how to control the network requests interception for any of your application resources" seems misleading/erroneous, and "configure" should be "implement you own".

userquin commented 8 months ago

PWA plugin options:

If you use generateSW strategy, then, you only need to configure the runtime caching plugins (via workbox.runtimeCaching), check VitePWA options codesnippet here https://vite-pwa-org.netlify.app/workbox/generate-sw.html#cache-external-resources

vite-plugin-pwa is a Workbox wrapper, you should be familiar with Workbox.

userquin commented 8 months ago

Types can be found here:

userquin commented 8 months ago

@sgpinkus Feel free to send a PR if you want to modify/add some entries :pray:

sgpinkus commented 8 months ago

Thanks for the pointers. Will be sure to PR to clarify doc once I understand how to cache-first and other policies configured and working correctly.