Skip to content

Commit

Permalink
Unfinished PWA Service Worker
Browse files Browse the repository at this point in the history
  • Loading branch information
thedoggybrad authored Dec 23, 2022
1 parent 865fe88 commit 7569f46
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pwa/service_worker_main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict'

const CACHE_NAME = 'cache-v2';
// The files we want to cache
const resourceList = [
'/',
'https://thedoggybrad.github.io/qrscanner/index.html',

];

self.addEventListener('install', event => {
event.waitUntil(caches.open(CACHE_NAME).then(cache => {
return cache.addAll(resourceList);
}));
});

function addToCache(cacheName, resourceList) {
caches.open(cacheName).then(cache => {
return cache.addAll(resourceList);
});
}

self.addEventListener('fetch', event => {
event.respondWith(caches.match(event.request).then(response => {
return response || fetch(event.request);
}));
});

0 comments on commit 7569f46

Please sign in to comment.