-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice-worker.js
33 lines (30 loc) · 915 Bytes
/
service-worker.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
const CACHE_NAME = 'hsv_cache';
const URLS_TO_CACHE = [
'./index.html',
'./javascripts/jquery-3.5.1.js',
'./javascripts/anvaka_panzoom.js',
'./javascripts/ui_functions.js',
'./javascripts/file_functions.js',
'./javascripts/tag_functions.js',
'./javascripts/main.js',
'./stylesheets/style.css',
'https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css'
];
self.addEventListener('fetch', (event) => {
event.respondWith(
fetch(event.request).catch(()=>{
caches.match(event.request).then((cachedResponse) => {
if (cachedResponse) {
return cachedResponse;
}
})
})
);
});
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => {
return cache.addAll(URLS_TO_CACHE);
})
);
});