1'use strict'; 2 3const PREFIX = 'binebi.test'; 4const HASH = '0a2b8979'; // Computed at build time. 5const OFFLINE_CACHE = `${PREFIX}-${HASH}`; 6 7self.addEventListener('install', function(event) { 8 event.waitUntil( 9 caches.open(OFFLINE_CACHE).then(function(cache) { 10 return cache.addAll([ 11 '/assets/uploads', 12 '/favicon.ico', 13 '/assets/frontend/css/apps.min.css?v=140', 14 '/assets/frontend/js/apps.min.js?v=140', 15 '/assets/frontend/js/mapbox.js', 16 '/assets/frontend/js/maps.js', 17 ]); // Computed at build time. 18 }) 19 ); 20}); 21 22self.addEventListener('activate', function(event) { 23 // Delete old asset caches. 24 event.waitUntil( 25 caches.keys().then(function(keys) { 26 return Promise.all( 27 keys.map(function(key) { 28 if ( 29 key != OFFLINE_CACHE && 30 key.startsWith(`${PREFIX}-`) 31 ) { 32 return caches.delete(key); 33 } 34 }) 35 ); 36 }) 37 ); 38}); 39 40self.addEventListener('fetch', function(event) { 41 if (event.request.mode == 'navigate') { 42 console.log('Handling fetch event for', event.request.url); 43 console.log(event.request); 44 event.respondWith( 45 fetch(event.request).catch(function(exception) { 46 // The `catch` is only triggered if `fetch()` throws an exception, 47 // which most likely happens due to the server being unreachable. 48 console.error( 49 'Fetch failed; returning offline page instead.', 50 exception 51 ); 52 return caches.open(OFFLINE_CACHE).then(function(cache) { 53 return cache.match('/'); 54 }); 55 }) 56 ); 57 } else { 58 // Itâs not a request for an HTML document, but rather for a CSS or SVG 59 // file or whatever⦠60 event.respondWith( 61 caches.match(event.request).then(function(response) { 62 return response || fetch(event.request); 63 }) 64 ); 65 } 66 67});
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.