-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
59 lines (49 loc) · 1.75 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const cacheName = "pwa-cache2";
self.addEventListener("install", evt => {
evt.waitUntil(
caches.open(cacheName).then(cache => {
return cache.addAll([
"./",
"./index.html",
"./css/global.css",
"./css/home.css",
"./js/jquery-3.5.1.js",
"./js/homeScript.js",
"./public/logo.png",
"./public/img/back_button.png",
"./public/img/next_button.png",
"./public/img/play_button.png",
"./public/img/pause_button.png",
"./public/img/smooth_rain.png",
"./public/img/heavy_rain.png",
"./public/img/heavy_thunder_rain.png",
"./public/img/ioga_icon.png",
"./public/img/meditation_icon.png",
"./public/img/sleep_icon.png",
"./public/img/facebook_icon.png",
"./public/img/twitter_icon.png",
"./public/img/whatsapp_icon.png",
])
})
)
})
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});
self.addEventListener("activate", function(evt) {
console.log("[ServiceWorker] Activated")
evt.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(cacheNames.map(function(thisCacheName) {
if (thisCacheName !== cacheName) {
console.log("[ServiceWorker] Removing cached files from", thisCacheName);
return caches.delete(thisCacheName);
}
}))
})
)
})