-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice-worker.js
30 lines (27 loc) · 996 Bytes
/
service-worker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const versionNumber = 3.3;
self.addEventListener('install', e => {
try {
e.waitUntil(
caches.open('static').then(cache => {
return cache.addAll([
'./',
'./portfolio/images/sequoiatree.png',
'./portfolio/images/EyeTerraEdit.png',
'./skllc.css'
]);
})
)
console.log("sw.js - SW registered successfully!");
} catch (error) {
console.log("SW registration failed. " + error);
}
});
// these logs will only print if a change is made to this file, and must be inspected in the browser. Go to application, then service workers, then click on stopwaiting,
self.addEventListener('fetch', e => {
e.respondWith(
caches.match(e.request).then(response => {
// if it is in the cache, fetch the request. else fetch it from the network
return response || fetch(e.request);
})
)
})