-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice-worker.js
32 lines (29 loc) · 911 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
const CACHE_NAME = 'pwa-cache-v5';
const urlsToCache = [
'index.html',
'games/nerdle/index.html',
'games/pipes/index.html',
'games/memory/index.html',
'games/minesweeper/index.html',
'games/snake/index.html',
'games/soccer-juggle/index.html',
'games/water-ring-toss/index.html',
'games/waveform/index.html',
'games/bubble-pop/index.html',
'games/breakout/index.html',
'games/space-shooter/index.html',
'images/icons/web-app-manifest-192x192.png',
'images/icons/web-app-manifest-512x512.png'
];
// Install the service worker and cache resources
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME).then(cache => cache.addAll(urlsToCache))
);
});
// Serve cached resources when offline
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request).then(response => response || fetch(event.request))
);
});