forked from bustEXZ/JSQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
83 lines (73 loc) · 1.91 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const NAME = 'jsp-v6'
const FILES = [
'./index.html',
'./style.css',
'./script.js',
'./404.html',
'./public/css/buttons.css',
'./public/css/code.css',
'./public/css/footer.css',
'./public/css/game.css',
'./public/css/header.css',
'./public/css/loader.css',
'./public/css/section.css',
'./public/js/contact.js',
'./public/js/functions.js',
'./public/js/algorithms.js',
'./public/js/patterns.js',
'./public/js/projects.js',
'./public/js/tasks.js',
'./public/js/theory.js',
'./public/js/helpers/animate-details.js',
'./public/js/helpers/generate-page.js',
'./public/js/helpers/hl.js',
'./public/js/helpers/init-handlers.js',
'./public/js/helpers/loader.js',
'./public/js/helpers/toggle-class.js',
'./public/js/questions/create-game.js',
'./public/js/questions/create-questions.js',
'./public/js/questions/questions.js',
'./public/icons/icon-64.png',
'./public/icons/icon-128.png',
'./public/icons/icon-150.png',
'./public/icons/icon-256.png',
'./public/icons/icon-512.png',
'./img/logo.png'
]
self.addEventListener('install', (e) => {
e.waitUntil(caches.open(NAME).then((cache) => cache.addAll(FILES)))
self.skipWaiting()
})
self.addEventListener('activate', (e) => {
e.waitUntil(
caches.keys().then((keys) =>
Promise.all(
keys.map((key) => {
if (key !== NAME) {
return caches.delete(key)
}
})
)
)
)
self.clients.claim()
})
self.addEventListener('fetch', (e) => {
e.respondWith(
caches
.match(e.request)
.then(
(response) =>
response ||
fetch(e.request).then((response) =>
caches.open(NAME).then((cache) => {
if (e.request.method === 'GET') {
cache.put(e.request, response.clone())
}
return response
})
)
)
.catch(() => caches.match('./404.html'))
)
})