From 70e67a686b812c3ddf3a33c04e09cbd85ef9a48b Mon Sep 17 00:00:00 2001 From: Yifei Zhang Date: Thu, 26 Oct 2023 00:06:09 +0800 Subject: [PATCH] Revert "fix serviceWorker cache: auto caching files by workbox" --- public/serviceWorker.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/public/serviceWorker.js b/public/serviceWorker.js index 2e1d60b98d2..f5a24b70176 100644 --- a/public/serviceWorker.js +++ b/public/serviceWorker.js @@ -1,21 +1,15 @@ const CHATGPT_NEXT_WEB_CACHE = "chatgpt-next-web-cache"; -importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-sw.js'); - self.addEventListener("activate", function (event) { console.log("ServiceWorker activated."); }); -workbox.core.clientsClaim(); -self.addEventListener("message", (event) => { - if (event.data && event.data.type === "SKIP_WAITING") { - self.skipWaiting(); - } +self.addEventListener("install", function (event) { + event.waitUntil( + caches.open(CHATGPT_NEXT_WEB_CACHE).then(function (cache) { + return cache.addAll([]); + }), + ); }); -workbox.routing.registerRoute( - new RegExp('/*'), - new workbox.strategies.StaleWhileRevalidate({ - cacheName: CHATGPT_NEXT_WEB_CACHE - }) -); +self.addEventListener("fetch", (e) => {});