forked from XiaoMo/ChatGPT-Next-Web
fix serviceWorker cache
This commit is contained in:
parent
06e043d3f1
commit
0dcbfd746e
@ -1,15 +1,21 @@
|
|||||||
const CHATGPT_NEXT_WEB_CACHE = "chatgpt-next-web-cache";
|
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) {
|
self.addEventListener("activate", function (event) {
|
||||||
console.log("ServiceWorker activated.");
|
console.log("ServiceWorker activated.");
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener("install", function (event) {
|
workbox.core.clientsClaim();
|
||||||
event.waitUntil(
|
self.addEventListener("message", (event) => {
|
||||||
caches.open(CHATGPT_NEXT_WEB_CACHE).then(function (cache) {
|
if (event.data && event.data.type === "SKIP_WAITING") {
|
||||||
return cache.addAll([]);
|
self.skipWaiting();
|
||||||
}),
|
}
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener("fetch", (e) => {});
|
workbox.routing.registerRoute(
|
||||||
|
new RegExp('/*'),
|
||||||
|
new workbox.strategies.StaleWhileRevalidate({
|
||||||
|
cacheName: CHATGPT_NEXT_WEB_CACHE
|
||||||
|
})
|
||||||
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user