1// Cache limité à trois images publiques. Aucune page, API ou donnée privée. 2const CACHE_NAME = 'lbo-cache-v4-public'; 3const CORE_ASSETS = ['icon-192.png', 'icon-512.png', 'logo-lbo.png']; 4const PUBLIC_URLS = CORE_ASSETS.map(p => new URL(p, self.registration.scope).href); 5self.addEventListener('install', event => { 6 self.skipWaiting(); 7 event.waitUntil(caches.open(CACHE_NAME).then(cache => cache.addAll(PUBLIC_URLS)).catch(() => {})); 8}); 9self.addEventListener('activate', event => { 10 event.waitUntil(caches.keys().then(keys => Promise.all( 11 keys.filter(k => k.startsWith('lbo-cache-') && k !== CACHE_NAME).map(k => caches.delete(k)) 12 )).then(() => self.clients.claim())); 13}); 14self.addEventListener('fetch', event => { 15 if (event.request.method !== 'GET' || !PUBLIC_URLS.includes(event.request.url)) return; 16 event.respondWith(fetch(event.request).then(response => { 17 if (response.ok && response.type === 'basic') { 18 const copy = response.clone(); 19 event.waitUntil(caches.open(CACHE_NAME).then(c => c.put(event.request, copy)).catch(() => {})); 20 } 21 return response; 22 }).catch(() => caches.match(event.request))); 23});
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.