cdn

Log | Files | Refs | Activity

root / app / static / sw.js

sw.js (1028B)


      1 // This service worker intentionally does NOT cache anything.
      2 // It exists only so the site satisfies PWA "installability" requirements
      3 // (Add to Home Screen / desktop install) while every request still goes
      4 // straight to the network. Directory listings and files here can change
      5 // at any time, so nothing is ever served from a cache.
      6 
      7 self.addEventListener("install", (event) => {
      8   // Activate the new worker immediately, don't wait for old tabs to close.
      9   self.skipWaiting();
     10 });
     11 
     12 self.addEventListener("activate", (event) => {
     13   event.waitUntil(
     14     (async () => {
     15       // Defensive cleanup: if a cache was ever created by a previous
     16       // version of this worker, delete it so nothing stale lingers.
     17       const keys = await caches.keys();
     18       await Promise.all(keys.map((key) => caches.delete(key)));
     19       await self.clients.claim();
     20     })()
     21   );
     22 });
     23 
     24 self.addEventListener("fetch", (event) => {
     25   // Always hit the network. No cache.match, no cache.put — ever.
     26   event.respondWith(fetch(event.request));
     27 });
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror