PawMatchAI / service-worker.js
DawnC's picture
Update service-worker.js
2b342f6
raw
history blame
1 kB
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('Cache opened successfully');
return cache.addAll(urlsToCache);
})
.catch(function(error) {
console.error('Cache initialization failed:', error);
})
);
});
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request)
.then(function(response) {
if (response) {
return response;
}
return fetch(event.request);
})
.catch(function(error) {
console.error('Fetch failed:', error);
return fetch(event.request);
})
);
});