-
Notifications
You must be signed in to change notification settings - Fork 1
/
sw.js
29 lines (27 loc) · 842 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
const version = "0.1.0";
const cacheName = `grejbox-${version}`;
// Caching homepage and assets.
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open(cacheName).then(function(cache) {
return cache.addAll([
'/',
'/index.html',
'/index.html?homescreen=1',
'/?homescreen=1',
'/grej.0.aac',
'/grej.1.aac',
]).then(function() {
self.skipWaiting();
});
})
);
});
// Check in our cache and return the cached version of the assets if we have them.
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});