1// To clear cache on devices, always increase APP_VER number after making changes. 2// The app will serve fresh content right away or after 2-3 refreshes (open / close) 3var APP_NAME = 'BuliTickets24'; 4var APP_VER = '2.55L'; 5var CACHE_NAME = APP_NAME + '-' + APP_VER; 6 7// Files required to make this app work offline. 8// Add all files you want to view offline below. 9// Leave REQUIRED_FILES = [] to disable offline. 10var REQUIRED_FILES = [ 11 // Styles 12 '/wp-content/themes/ecomall-child/style.min.css', 13 '/wp-content/themes/ecomall/style.css', 14 '/wp-content/themes/ecomall-child/css/vendor/bootstrap.min.css', 15 '/wp-content/themes/ecomall-child/css/vendor/splide.min.css', 16 '/wp-content/uploads/ecomallchild.css', 17 '/wp-content/themes/ecomall/css/reset.css', 18 '/wp-content/themes/ecomall/css/responsive.css', 19 '/wp-content/plugins/themesky/css/swiper-bundle.min.css', 20 '/wp-content/themes/ecomall/css/tb-icons.min.css', 21 '/wp-content/plugins/themesky/css/themesky.css', 22 // Scripts 23 '/wp-content/themes/ecomall-child/js/source/app.js', 24 '/wp-content/themes/ecomall-child/js/source/app_livescore.js', 25 '/wp-content/themes/ecomall-child/js/source/app_tracking.js', 26 '/wp-content/themes/ecomall-child/js/vendor/bootstrap.min.js', 27 '/wp-content/themes/ecomall/js/main.js', 28 '/wp-content/themes/ecomall/js/SmoothScroll.min.js', 29 '/wp-content/plugins/themesky/js/swiper-bundle.min.js', 30 '/wp-content/plugins/themesky/js/themesky.js', 31 // Fonts 32 '/fonts/fontawesome-all.min.css', 33]; 34 35// Service Worker Diagnostic. Set true to get console logs. 36var APP_DIAG = false; 37 38//Service Worker Function Below. 39self.addEventListener('install', function(event) { 40 event.waitUntil( 41 caches.open(CACHE_NAME) 42 .then(function(cache) { 43 //Adding files to cache 44 return cache.addAll(REQUIRED_FILES); 45 }).catch(function(error) { 46 //Output error if file locations are incorrect 47 if(APP_DIAG){console.log('Service Worker Cache: Error Check REQUIRED_FILES array in _service-worker.js - files are missing or path to files is incorrectly written - ' + error);} 48 }) 49 .then(function() { 50 //Install SW if everything is ok 51 return self.skipWaiting(); 52 }) 53 .then(function(){ 54 if(APP_DIAG){console.log('Service Worker: Cache is OK');} 55 }) 56 ); 57 if(APP_DIAG){console.log('Service Worker: Installed');} 58}); 59 60self.addEventListener('fetch', function(event) { 61 event.respondWith( 62 //Fetch Data from cache if offline 63 caches.match(event.request) 64 .then(function(response) { 65 if (response) {return response;} 66 67 return fetch(event.request); 68 } 69 ).catch(rejected => { 70 if(APP_DIAG){console.log(rejected);} 71 }) 72 ); 73 if(APP_DIAG){console.log('Service Worker: Fetching '+APP_NAME+'-'+APP_VER+' files from Cache');} 74}); 75 76self.addEventListener('activate', function(event) { 77 event.waitUntil(self.clients.claim()); 78 event.waitUntil( 79 //Check cache number, clear all assets and re-add if cache number changed 80 caches.keys().then(cacheNames => { 81 return Promise.all( 82 cacheNames 83 .filter(cacheName => (cacheName.startsWith(APP_NAME + "-"))) 84 .filter(cacheName => (cacheName !== CACHE_NAME)) 85 .map(cacheName => caches.delete(cacheName)) 86 ); 87 }) 88 ); 89 if(APP_DIAG){console.log('Service Worker: Activated')} 90});
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.