-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
30 lines (26 loc) · 903 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
30
'use strict'
const CACHE_NAME = 'peacefulsearch';
// The files we want to cache
const resourceList = [
'/',
'https://thedoggybrad.github.io/peacefulsearch/index.html',
'https://cdn.jsdelivr.net/gh/thedoggybrad/peacefulsearch@main/favicon.png',
'https://cdn.jsdelivr.net/gh/thedoggybrad/peacefulsearch@main/style.css',
'https://fonts.googleapis.com/css?family=Open+Sans:400,700',
'https://cse.google.com/cse.js?cx=f3cd3674f03c44b40'
];
self.addEventListener('install', event => {
event.waitUntil(caches.open(CACHE_NAME).then(cache => {
return cache.addAll(resourceList);
}));
});
function addToCache(cacheName, resourceList) {
caches.open(cacheName).then(cache => {
return cache.addAll(resourceList);
});
}
self.addEventListener('fetch', event => {
event.respondWith(caches.match(event.request).then(response => {
return response || fetch(event.request);
}));
});