1const CACHE_NAME = 'ua-coins-cache-v4'; 2const urlsToCache = [ 3 '/css/bootstrap-5.3.8.min.css', 4 '/css/index.css', 5 '/css/profile.css', 6 '/js/jquery-3.7.1.min.js', 7 '/js/bootstrap.bundle-5.3.8.min.js', 8 '/js/script.js', 9]; 10 11self.addEventListener('install', function(event) { 12 event.waitUntil( 13 caches.open(CACHE_NAME) 14 .then(function(cache) { 15 return cache.addAll(urlsToCache); 16 }) 17 ); 18 self.skipWaiting(); 19}); 20 21self.addEventListener('activate', function(event) { 22 event.waitUntil( 23 caches.keys().then(function(cacheNames) { 24 return Promise.all(cacheNames.map(function(cacheName) { 25 if (cacheName !== CACHE_NAME) { 26 return caches.delete(cacheName); 27 } 28 return Promise.resolve(); 29 })); 30 }).then(function() { 31 return self.clients.claim(); 32 }) 33 ); 34}); 35 36self.addEventListener('fetch', function(event) { 37 var url = new URL(event.request.url); 38 39 if (url.origin === self.location.origin && (url.pathname.endsWith('.js') || url.pathname.endsWith('.css'))) { 40 event.respondWith( 41 fetch(event.request) 42 .then(function(response) { 43 var responseClone = response.clone(); 44 caches.open(CACHE_NAME).then(function(cache) { 45 cache.put(event.request, responseClone); 46 }); 47 return response; 48 }) 49 .catch(function() { 50 return caches.match(event.request); 51 }) 52 ); 53 return; 54 } 55});
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.