var cacheName='weatherPWA-step-6-1';var dataCacheName='weatherData-v1';var filesToCache=['/','/index.html','./scripts/appLogic.js','./styles/main.css','./resources/back.svg','./resources/loading.svg','./resources/refresh.svg'];self.addEventListener('install',function(e){console.log('[ServiceWorker] Install');e.waitUntil(caches.open(cacheName).then(function(cache){console.log('[ServiceWorker] Caching app shell');return cache.addAll(filesToCache)}))});self.addEventListener('activate',function(e){console.log('[ServiceWorker] Activate');e.waitUntil(caches.keys().then(function(keyList){return Promise.all(keyList.map(function(key){if(key!==cacheName&&key!==dataCacheName){console.log('[ServiceWorker] Removing old cache',key);return caches.delete(key)}}))}));return self.clients.claim()});self.addEventListener('fetch',function(e){console.log('[ServiceWorker] Fetch',e.request.url);var weatherURL;var newsURL='https://content.guardianapis.com/world';var articleURL;console.log(typeof e.request.url);if(e.request.url.includes(newsURL)){e.respondWith(caches.open(dataCacheName).then(function(cache){return fetch(e.request).then(function(response){cache.put(e.request.url,response.clone());return response})}))}
else{e.respondWith(caches.match(e.request).then(function(response){return response||fetch(e.request)}))}})
var cacheName='weatherPWA-step-6-1';var dataCacheName='weatherData-v1';var filesToCache=['./','./index.html','./scripts/appLogic.js','./styles/main.css','./resources/back.svg','./resources/loading.svg','./resources/refresh.svg'];self.addEventListener('install',function(e){console.log('[ServiceWorker] Install');e.waitUntil(caches.open(cacheName).then(function(cache){console.log('[ServiceWorker] Caching app shell');return cache.addAll(filesToCache)}))});self.addEventListener('activate',function(e){console.log('[ServiceWorker] Activate');e.waitUntil(caches.keys().then(function(keyList){return Promise.all(keyList.map(function(key){if(key!==cacheName&&key!==dataCacheName){console.log('[ServiceWorker] Removing old cache',key);return caches.delete(key)}}))}));return self.clients.claim()});self.addEventListener('fetch',function(e){console.log('[ServiceWorker] Fetch',e.request.url);var weatherURL;var newsURL='https://content.guardianapis.com/world';var articleURL;console.log(typeof e.request.url);if(e.request.url.includes(newsURL)){e.respondWith(caches.open(dataCacheName).then(function(cache){return fetch(e.request).then(function(response){cache.put(e.request.url,response.clone());return response})}))}
else{e.respondWith(caches.match(e.request).then(function(response){return response||fetch(e.request)}))}})
Update file paths