diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 00000000..9bae1f62 --- /dev/null +++ b/public/sw.js @@ -0,0 +1,15 @@ +// Retires the service worker the old Gatsby site installed in visitors' browsers. +// Safe to delete once old registrations have had months to expire. +self.addEventListener("install", () => self.skipWaiting()); + +self.addEventListener("activate", (event) => { + event.waitUntil( + (async () => { + for (const key of await caches.keys()) await caches.delete(key); + await self.registration.unregister(); + for (const client of await self.clients.matchAll({ type: "window" })) { + client.navigate(client.url); + } + })(), + ); +});