-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
38 lines (37 loc) · 984 Bytes
/
sw.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
31
32
33
34
35
36
37
38
version = "0.1.13";
self.addEventListener('install', function(e) {
console.log(`Service Worker v${version} Installed`);
e.waitUntil(
caches.open('the-magic-cache').then(function(cache) {
console.log("Caching Resources");
return cache.addAll([
'/',
'/index.html',
'/js/extension.js',
'/js/main.js',
'/js/vue.global.prod.js',
'/css/main.css',
'/assets/logo.png',
'/assets/cantarell.ttf',
'/assets/fira-code-regular.ttf',
'/assets/jost-bold.otf',
'/assets/bg.jpg',
'/favicon.ico'
]);
})
);
});
self.addEventListener('fetch', function(event) {
if(event.request.url.endsWith("/version")){
event.respondWith(new Response(version, {
status: 200,
statusText: "OK" //
}));
} else {
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
}
});