PawMatchAI / service-worker.js
DawnC's picture
Update service-worker.js
bc241ad
raw
history blame
614 Bytes
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);
})
);
});