From 779500d22e172fc336594c76755603ab83883f9c Mon Sep 17 00:00:00 2001 From: pavel Date: Thu, 12 Feb 2026 20:53:50 +0100 Subject: [PATCH] fix site load --- frontend/public/sw.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/frontend/public/sw.js b/frontend/public/sw.js index c5efb91..c8d352d 100644 --- a/frontend/public/sw.js +++ b/frontend/public/sw.js @@ -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; + }); }) ); });