Skip to content

fix: remove sw cache storage entries when using self destroying option #609

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

Merged
merged 1 commit into from
Nov 25, 2023

Conversation

userquin
Copy link
Member

@userquin userquin commented Nov 25, 2023

This PR also includes:

  • check if the client is a WindowClient before calling navigate, it can be Push/Sync worker (missing navigate method)
  • bump to pnpm 8.11.0

closes #560

Copy link

netlify bot commented Nov 25, 2023

Deploy Preview for vite-plugin-pwa-legacy ready!

Name Link
🔨 Latest commit 7152c61
🔍 Latest deploy log https://app.netlify.com/sites/vite-plugin-pwa-legacy/deploys/65622e55ca4ad000088d2006
😎 Deploy Preview https://deploy-preview-609--vite-plugin-pwa-legacy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@userquin userquin merged commit df8b4b0 into main Nov 25, 2023
@userquin userquin deleted the userquin/feat-self-destroying-cleanup-caches branch November 25, 2023 17:36
@Doctor-wu
Copy link

@userquin I noticed that you deleted all the keys in cache-storage, maybe deleting keys generated by this plugin will be better?

@userquin
Copy link
Member Author

@Doctor-wu this plugin doesn't add any entry to the cache storage, the sw cache storage is per location (sw origin)

@Doctor-wu
Copy link

@userquin users can use sw outside this plugin, and they can add other caches even if that is not recommended, but we can't prevent users from doing that. Thus maybe we can delete the cache literally declared in the workbox's runtimeCaching, so that we won't delete the cache outside this plugin

@userquin
Copy link
Member Author

userquin commented Nov 26, 2023

@Doctor-wu we cannot detect user entries, you can use a custom one https://vite-pwa-org.netlify.app/guide/unregister-service-worker.html#custom-selfdestroying-service-worker

EDIT: if missing await until new version installed (prompt should be shown a few seconds later)

@Doctor-wu
Copy link

@userquin Got you~, maybe we can inform users in docs that we will delete all the cache when they use self-destroying

@userquin
Copy link
Member Author

userquin commented Nov 26, 2023

@userquin Got you~, maybe we can inform users in docs that we will delete all the cache when they use self-destroying

Check the INFO block:

imagen

@Doctor-wu
Copy link

Sry, I only watched the danger block😂, and now that will be pretty good~

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

Successfully merging this pull request may close these issues.

Self destroying service worker should clean up cache storage
2 participants