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

current logic doesn't delete cache storage entries #11

Open
userquin opened this issue Nov 25, 2023 · 0 comments
Open

current logic doesn't delete cache storage entries #11

userquin opened this issue Nov 25, 2023 · 0 comments

Comments

@userquin
Copy link

userquin commented Nov 25, 2023

Should add cleanup logic:

self.addEventListener('install', function(e) {
  self.skipWaiting();
});
self.addEventListener('activate', function(e) {
  self.registration.unregister()
      .then(function() {
        return self.clients.matchAll();
      })
      .then(function(clients) {
        clients.forEach(client => client.navigate(client.url));
        return Promise.resolve();
      })
      .then(() => {
        self.caches.keys().then(function(cacheNames) {
          Promise.all(
            cacheNames.map(function(cacheName) {
              return self.caches.delete(cacheName);
            })
          )
        })
      });
});
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

1 participant