1/* ============================================================= 2 FOCAL POINT â Service Worker 3 Strategy: Cache-first for static assets, network-first for pages 4 ============================================================= */ 5const CACHE_NAME = "focal-point-v1"; 6const STATIC_ASSETS = [ 7 "/", 8 "/band", 9 "/schedule", 10 "/videos", 11 "/contact", 12 "/manifest.json", 13]; 14 15self.addEventListener("install", (event) => { 16 event.waitUntil( 17 caches.open(CACHE_NAME).then((cache) => cache.addAll(STATIC_ASSETS)) 18 ); 19 self.skipWaiting(); 20}); 21 22self.addEventListener("activate", (event) => { 23 event.waitUntil( 24 caches.keys().then((keys) => 25 Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k))) 26 ) 27 ); 28 self.clients.claim(); 29}); 30 31self.addEventListener("fetch", (event) => { 32 const { request } = event; 33 const url = new URL(request.url); 34 35 // Skip non-GET and cross-origin audio/video requests 36 if (request.method !== "GET") return; 37 if (url.hostname.includes("youtube") || url.hostname.includes("reverbnation")) return; 38 if (url.hostname.includes("focalpoint5.com")) return; // audio streams 39 40 event.respondWith( 41 caches.match(request).then((cached) => { 42 const networkFetch = fetch(request) 43 .then((response) => { 44 if (response.ok && url.origin === self.location.origin) { 45 const clone = response.clone(); 46 caches.open(CACHE_NAME).then((cache) => cache.put(request, clone)); 47 } 48 return response; 49 }) 50 .catch(() => cached); 51 // For navigation requests: network-first, fall back to cache 52 if (request.mode === "navigate") return networkFetch; 53 // For assets: cache-first 54 return cached || networkFetch; 55 }) 56 ); 57});
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.