-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
57 lines (50 loc) · 1.28 KB
/
Copy pathsw.js
File metadata and controls
57 lines (50 loc) · 1.28 KB
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
---
layout: null
---
const staticCacheName = "gdad-s-river-static-v120";
console.log("installing service worker");
const filesToCache = [
"/",
{% for page in site.html_pages %}
'{{ page.url }}',
{% endfor %}
{% for post in site.posts %}
'{{ post.url }}',
{% endfor %}
"/assets/images/bhavri-github-callbacks.png",
"/assets/images/bhavri-github-issues.png",
"/assets/images/jakethecake-svg-line-anime.png",
"/assets/images/svg-animated-mast-text-shapes-tweet.png",
"css/main.css",
"/about/",
"/index.html"
];
self.addEventListener("install", function(e){
self.skipWaiting();
e.waitUntil(
caches.open(staticCacheName).then(function(cache){
return cache.addAll(filesToCache);
})
)
});
self.addEventListener("activate", function(e){
e.waitUntil(
caches.keys().then(function(cacheNames){
return Promise.all(
cacheNames.filter(function(cacheName){
return cacheName.startsWith("gdad-s-river-static-")
&& cacheName != staticCacheName;
}).map(function(cacheName){
return caches.delete(cacheName);
})
)
})
)
});
self.addEventListener("fetch", function(e){
e.respondWith(
caches.match(e.request).then(function(response) {
return response || fetch(e.request);
})
)
});