Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#3013 from jessegpt/main
Browse files Browse the repository at this point in the history
  • Loading branch information
Yidadaa authored Oct 16, 2023
2 parents 4a56e9c + 0dcbfd7 commit cc565cf
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions public/serviceWorker.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
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.");
});

self.addEventListener("install", function (event) {
event.waitUntil(
caches.open(CHATGPT_NEXT_WEB_CACHE).then(function (cache) {
return cache.addAll([]);
}),
);
workbox.core.clientsClaim();
self.addEventListener("message", (event) => {
if (event.data && event.data.type === "SKIP_WAITING") {
self.skipWaiting();
}
});

self.addEventListener("fetch", (e) => {});
workbox.routing.registerRoute(
new RegExp('/*'),
new workbox.strategies.StaleWhileRevalidate({
cacheName: CHATGPT_NEXT_WEB_CACHE
})
);

0 comments on commit cc565cf

Please sign in to comment.