const CACHE_NAME = 'lut-cam-cache-v1'; const urlsToCache = [ '/', './', 'index.html', 'lut.js', 'service-worker.js', 'android-icon-192x192.png', 'android-icon-512x512.png', 'favicon.ico', 'favicon-16x16.png', 'favicon-32x32.png', 'favicon-96x96.png', 'apple-icon-57x57.png', 'apple-icon-60x60.png', 'apple-icon-72x72.png', 'apple-icon-76x76.png', 'apple-icon-114x114.png', 'apple-icon-120x120.png', 'apple-icon-144x144.png', 'apple-icon-152x152.png' ]; self.addEventListener('install', event => { event.waitUntil( caches.open(CACHE_NAME) .then(cache => { return cache.addAll(urlsToCache); }) ); }); self.addEventListener('fetch', event => { event.respondWith( caches.match(event.request) .then(response => { if (response) { return response; } return fetch(event.request); }) ); });