Skip to content
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

Doc around caching strategy is confusing. #106

Open
sgpinkus opened this issue Nov 27, 2023 · 4 comments
Open

Doc around caching strategy is confusing. #106

sgpinkus opened this issue Nov 27, 2023 · 4 comments

Comments

@sgpinkus
Copy link

sgpinkus commented Nov 27, 2023

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".

@sgpinkus sgpinkus changed the title Doc arounf caching strategy is confusing. Doc around caching strategy is confusing. Nov 27, 2023
@userquin
Copy link
Member

userquin commented Nov 27, 2023

PWA plugin options:

  • generateSW strategy, use workbox PWA plugin option
  • injectManifest strategy, use injectManifest PWA plugin option

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

userquin commented Nov 27, 2023

Types can be found here:

@userquin
Copy link
Member

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

@sgpinkus
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants