1// Cache name - replace v1 with v2, v3, etc to clear service worker cache on your server 2var CACHE_NAME = 'Cache-Version-v1'; 3 4// Files required to make this app work offline 5var REQUIRED_FILES = [ 6 'index.php' 7]; 8 9self.addEventListener('install', function(event) { 10 // Perform install step: loading each required file into cache 11 event.waitUntil( 12 caches.open(CACHE_NAME) 13 .then(function(cache) { 14 // Add all offline dependencies to the cache 15 return cache.addAll(REQUIRED_FILES); 16 }) 17 .then(function() { 18 return self.skipWaiting(); 19 }) 20 ); 21}); 22 23self.addEventListener('fetch', function(event) { 24 event.respondWith( 25 caches.match(event.request) 26 .then(function(response) { 27 // Cache hit - return the response from the cached version 28 if (response) { 29 return response; 30 } 31 // Not in cache - return the result from the live server 32 // `fetch` is essentially a "fallback" 33 return fetch(event.request); 34 } 35 ) 36 ); 37}); 38 39self.addEventListener('activate', function(event) { 40 // Calling claim() to force a "controllerchange" event on navigator.serviceWorker 41 event.waitUntil(self.clients.claim()); 42});
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.