-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkerbee.js
21 lines (18 loc) · 924 Bytes
/
workerbee.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const cacheVersion = "cachev3";
const files = ["app.html", "js/cookbook.js", "js/data.js", "js/display.js", "js/main.js", "js/online.js", "css/custom.css",
"css/normalize.css", "css/skeleton.css", "js/fraction.js", "js/he.js", "js/jquery.js", "js/jquery-ui.js",
"js/jquery.ui.touch-punch.js", "js/pouchdb.js", "font/MaterialIcons.woff2"
];
self.addEventListener("install", e => {
e.waitUntil(caches.open(cacheVersion).then(cache => cache.addAll(files)));
self.skipWaiting();
});
self.addEventListener("activate", e => {
e.waitUntil(caches.keys().then(keyList => Promise.all(keyList.map(key => {
if (key !== cacheVersion) { return caches.delete(key); }
}))));
self.clients.claim();
});
self.addEventListener("fetch", e => {
e.respondWith(caches.open(cacheVersion).then(cache => cache.match(e.request).then(response => response || fetch(e.request))));
});