forked from NajmAjmal/monero-webminer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
serviceworker.js
33 lines (31 loc) · 878 Bytes
/
serviceworker.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
self.addEventListener('install', event => {
event.waitUntil(
caches.open('mining-cache').then(cache => {
return cache.addAll([
'/',
'/index.html',
'/favicon.ico',
'/script.js'
]);
})
);
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request).then(response => {
return response || fetch(event.request);
})
);
});
// Add the following code to register the web app manifest
if ('serviceWorker' in navigator && 'PushManager' in window) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('serviceworker.js')
.then(registration => {
console.log('Service Worker registered with scope:', registration.scope);
})
.catch(error => {
console.error('Service Worker registration failed:', error);
});
});
}