Spaces:
Running
on
Zero
Running
on
Zero
File size: 614 Bytes
e9b92bb bc241ad e9b92bb bc241ad a59a059 bc241ad a59a059 |
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 |
const CACHE_NAME = 'pawmatch-v1';
const urlsToCache = [
'./',
'./manifest.json',
'./assets/icon-192.png',
'./assets/icon-512.png'
];
// 安裝事件處理器
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache) {
console.log('快取開啟');
return cache.addAll(urlsToCache);
})
);
});
// 請求處理器
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
return response || fetch(event.request);
})
);
});
|