-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsw.js
29 lines (26 loc) · 1015 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 cacheName = "radioglobal_cache_v1";
const cachedAssets = ["index.html", "crs-pf/stations.json", "img/radio.png", "img/radiox192.png", "svg/search.svg", "svg/play.svg", "svg/pause.svg", "svg/fav.svg", "svg/notfav.svg", "svg/pre.svg", "svg/next.svg", 'css/style.css', 'css/resp.css', 'js/script.js', 'js/radio.js', 'https://unpkg.com/localbase@0.7.5/dist/localbase.min.js'];
self.addEventListener("install", (e) => {
e.waitUntil(
caches.open(cacheName)
.then((cache) => { cache.addAll(cachedAssets) })
.then(() => self.skipWaiting())
);
});
self.addEventListener("activate", (e) => {
e.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map(cache => {
if (cache !== cacheName) {
return caches.delete(cache);
}
})
);
})
);
});
self.addEventListener("fetch", (e) => {
e.respondWith(fetch(e.request).catch(() => caches.match(e.request))
);
});