a tool for shared writing and social publishing

remove logs and add install + skipwaiting to worker

+10 -5
+1 -1
components/ServiceWorker.tsx
··· 4 4 export function ServiceWorker() { 5 5 useEffect(() => { 6 6 if ("serviceWorker" in navigator) { 7 - navigator.serviceWorker.register("/worker.js").then(console.log); 7 + navigator.serviceWorker.register("/worker.js"); 8 8 } 9 9 }, []); 10 10 return null;
+9 -4
public/worker.js
··· 1 1 self.addEventListener("fetch", (event) => { 2 - console.log("Handling fetch event for", event.request.url); 3 - 4 2 event.respondWith( 5 3 caches.open("minilink-user-assets").then(async (cache) => { 6 4 return cache 7 5 .match(event.request) 8 6 .then((response) => { 9 7 if (response) { 10 - console.log("cache match"); 11 8 return response; 12 9 } 13 - console.log("cache miss"); 14 10 return fetch(event.request.clone()); 15 11 }) 16 12 .catch((error) => { ··· 20 16 }), 21 17 ); 22 18 }); 19 + 20 + self.addEventListener("install", () => { 21 + // The promise that skipWaiting() returns can be safely ignored. 22 + self.skipWaiting(); 23 + 24 + // Perform any other actions required for your 25 + // service worker to install, potentially inside 26 + // of event.waitUntil(); 27 + });