Ver código fonte

Update service-worker.js

RobinLinus 5 anos atrás
pai
commit
2349d0b20b
1 arquivos alterados com 19 adições e 0 exclusões
  1. 19 0
      client/service-worker.js

+ 19 - 0
client/service-worker.js

@@ -33,3 +33,22 @@ self.addEventListener('fetch', function(event) {
     )
   );
 });
+
+
+self.addEventListener('activate', function(event) {
+  console.log('Updating Service Worker...')
+  event.waitUntil(
+    caches.keys().then(function(cacheNames) {
+      return Promise.all(
+        cacheNames.filter(function(cacheName) {
+          // Return true if you want to remove this cache,
+          // but remember that caches are shared across
+          // the whole origin
+          return true
+        }).map(function(cacheName) {
+          return caches.delete(cacheName);
+        })
+      );
+    })
+  );
+});