mo 1 year ago
parent
commit
563f6892e1
1 changed files with 6 additions and 1 deletions
  1. 6 1
      index.html

+ 6 - 1
index.html

@@ -176,11 +176,16 @@
         console.log(e, '这是js的报错 希望可以从错误类型判断')
       }, true)
       if ('serviceWorker' in navigator) {
-        console.log(caches.keys(), 'caches.keys()');
+
+        let flag = caches.keys().length > 0
+        console.log(caches.keys(), 'caches.keys()', `是否有缓存${flag}`);
         caches.keys().then(function (cacheNames) {
           cacheNames.forEach(function (cacheName) {
             caches.delete(cacheName);
           });
+          if (flag) {
+            window.location.reload()
+          }
         });
       }
       if (!isChrome()) {