1// Minimal service worker: network-first so listeners always get fresh shows, 2// with a cached copy as an offline fallback. Bump CACHE_VERSION to force refresh. 3const CACHE_VERSION = "bps-v2"; 4 5self.addEventListener("install", (event) => { 6 self.skipWaiting(); 7}); 8 9self.addEventListener("activate", (event) => { 10 event.waitUntil( 11 caches.keys().then((keys) => 12 Promise.all(keys.filter((k) => k !== CACHE_VERSION).map((k) => caches.delete(k))) 13 ).then(() => self.clients.claim()) 14 ); 15}); 16 17self.addEventListener("fetch", (event) => { 18 const req = event.request; 19 20 // Only handle same-origin GETs. Never touch audio streams or cross-origin media. 21 if (req.method !== "GET" || new URL(req.url).origin !== self.location.origin) { 22 return; 23 } 24 if (req.destination === "audio") { 25 return; 26 } 27 28 // Pages and JSON data should always revalidate against the server so edits 29 // show up promptly (GitHub Pages otherwise lets browsers cache HTML ~10 min). 30 const revalidate = 31 req.mode === "navigate" || 32 req.destination === "document" || 33 /\.json(\?|$)/.test(req.url); 34 35 event.respondWith( 36 fetch(revalidate ? new Request(req.url, { cache: "no-cache" }) : req) 37 .then((resp) => { 38 if (resp && resp.ok) { 39 const copy = resp.clone(); 40 caches.open(CACHE_VERSION).then((cache) => cache.put(req, copy)); 41 } 42 return resp; 43 }) 44 .catch(() => caches.match(req)) 45 ); 46});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.