1// Minimal service worker: makes the app installable and available offline. 2// Strategy: cache-first for same-origin GET requests, falling back to network 3// and caching the response for next time. The cache name is bumped to refresh. 4const CACHE = 'speedreader-v1' 5 6self.addEventListener('install', () => self.skipWaiting()) 7 8self.addEventListener('activate', (event) => { 9 event.waitUntil( 10 caches 11 .keys() 12 .then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))) 13 .then(() => self.clients.claim()), 14 ) 15}) 16 17self.addEventListener('fetch', (event) => { 18 const { request } = event 19 if (request.method !== 'GET' || new URL(request.url).origin !== self.location.origin) return 20 21 event.respondWith( 22 caches.match(request).then( 23 (cached) => 24 cached || 25 fetch(request).then((response) => { 26 if (response.ok) { 27 const copy = response.clone() 28 caches.open(CACHE).then((cache) => cache.put(request, copy)) 29 } 30 return response 31 }), 32 ), 33 ) 34})
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.