File size: 623 Bytes
e9b92bb
bc241ad
b3f92cc
 
 
 
bc241ad
e9b92bb
b3f92cc
 
 
 
 
 
 
 
727ad73
 
b3f92cc
 
 
 
 
 
 
ae22039
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
const CACHE_NAME = 'pawmatch-v1';
const urlsToCache = [
    '/',
    '/manifest.json',
    '/assets/icon-192.png',
    '/assets/icon-512.png'
];

self.addEventListener('install', (event) => {
    event.waitUntil(
        caches.open(CACHE_NAME)
            .then((cache) => {
                console.log('快取開啟成功');
                return cache.addAll(urlsToCache);
            })
    );
});

self.addEventListener('fetch', (event) => {
    event.respondWith(
        caches.match(event.request)
            .then((response) => {
                return response || fetch(event.request);
            })
    );
});