ChatGPT-Next-Web/public/serviceWorker.js

22 lines
561 B
JavaScript
Raw Normal View History

2023-03-27 09:41:44 +00:00
const CHATGPT_NEXT_WEB_CACHE = "chatgpt-next-web-cache";
2023-10-13 11:41:00 +00:00
importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-sw.js');
self.addEventListener("activate", function (event) {
console.log("ServiceWorker activated.");
2023-03-27 09:41:44 +00:00
});
2023-10-13 11:41:00 +00:00
workbox.core.clientsClaim();
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
2023-03-27 09:41:44 +00:00
});
2023-04-02 12:28:18 +00:00
2023-10-13 11:41:00 +00:00
workbox.routing.registerRoute(
new RegExp('/*'),
new workbox.strategies.StaleWhileRevalidate({
cacheName: CHATGPT_NEXT_WEB_CACHE
})
);