fix site load
All checks were successful
/ upload (release) Successful in 37s

This commit is contained in:
pavel 2026-02-12 20:53:50 +01:00
commit 779500d22e

View file

@ -1,9 +1,7 @@
const CACHE_NAME = 'agency-cache-v1';
const CACHE_NAME = 'agency-cache-v2';
const ASSETS = [
'/',
'/index.html',
'/src/main.js',
'/src/style.css',
'/manifest.json',
'/icon-192.png',
'/icon-512.png'
@ -18,9 +16,21 @@ self.addEventListener('install', (event) => {
});
self.addEventListener('fetch', (event) => {
// Only intercept http/https requests
if (!event.request.url.startsWith('http')) return;
event.respondWith(
caches.match(event.request).then((response) => {
return response || fetch(event.request);
// Return cached response if found, otherwise fetch from network
return response || fetch(event.request).catch(error => {
// If network fetch fails and it's a navigation request, return index.html
if (event.request.mode === 'navigate') {
return caches.match('/index.html');
}
// For assets, let the browser handle the failure normally
console.error('Fetch failed:', event.request.url, error);
throw error;
});
})
);
});