// https://codelabs.developers.google.com/codelabs/your-first-pwapp/#4

// update cache names any time any of the cached files change
const CACHE_NAME = 'static-cache-v193';

const FILES_TO_CACHE = [
	'/assets/checkin/app.html',
	'/assets/checkin/app.js',
	'/assets/checkin/icon-192.png',
	'/assets/checkin/icon-512.png',
	'/assets/checkin/manifest.json',
	'/assets/checkin/localforage.js',
	'/assets/checkin/style.css'
];

self.addEventListener('install', (evt) => {
	console.log('[ServiceWorker] Install');
	evt.waitUntil(
		caches.open(CACHE_NAME).then((cache) => {
			console.log('[ServiceWorker] Pre-caching offline page');
			return cache.addAll(FILES_TO_CACHE);
		})
	);
 	self.skipWaiting();
});

self.addEventListener('activate', (evt) => {
	console.log('[ServiceWorker] Activate');
	// Remove previous cached data from disk.
	evt.waitUntil(
	    caches.keys().then((keyList) => {
	      return Promise.all(keyList.map((key) => {
	        if (key !== CACHE_NAME) {
	          console.log('[ServiceWorker] Removing old cache', key);
	          return caches.delete(key);
	        }
	      }));
	    })
	);
	self.clients.claim();
});

self.addEventListener('fetch', (evt) => {
	console.log('[ServiceWorker] Fetch', evt.request.url);
	// don't cache application data or logging in
	if (evt.request.url.includes('/data') || evt.request.url.includes('/login')) {
		return;
	}
	// Use cache-first strategy. Only request resources from the server if they are not found in the cache.
	evt.respondWith(
	    caches.open(CACHE_NAME).then((cache) => {
	      return cache.match(evt.request)
			.then((response) => {
			  return response || fetch(evt.request);
			});
	    })
	);
});

@@ -167,9 +167,9 @@
 -v19
-3
+4
 ';%0A%0A
@@ -1381,97 +1381,75 @@
 %09// 
-Use cache-first strategy. Only request resources from the server if they are not found in
+replace the default fetch handler with our custom handler that uses
  the
@@ -1454,17 +1454,16 @@
 he cache
-.
 %0A%09evt.re
@@ -1476,78 +1476,212 @@
 ith(
-%0A%09    ca
+fet
 ch
+R
 es
-.open(CACHE_NAME).then((cache) =%3E %7B%0A%09      return cache.ma
+ources(evt));%0A%7D);%0A%0Aasync function fetchResources(evt) %7B%0A%09// first try to get resources from the server, falling back on the cache if the server cannot be reached%0A%09try %7B%0A%09%09const response = await fe
 tch(
@@ -1696,18 +1696,15 @@
 est)
+;
 %0A%09%09
-%09.then(
+if 
 (res
@@ -1712,19 +1712,12 @@
 onse
-) =%3E %7B%0A%09%09%09 
+.ok)
  ret
@@ -1732,51 +1732,83 @@
 onse
- %7C%7C fe
+;%0A%09%7D ca
 tch
+ 
 (e
-vt.request);%0A%09%09%09%7D);%0A%09    %7D)%0A%09
+rr) %7B%0A%09%09console.error(err);%0A%09%7D%0A%09return cache.match(evt.request
 );%0A%7D
-);%0A

Change caching strategy