From e3b3ff90a9683ddaf780fb8403d64ee0efa9f623 Mon Sep 17 00:00:00 2001 From: mariomitte Date: Mon, 10 Aug 2026 07:45:08 +0200 Subject: [PATCH] manifest manifest.webmanifest --- frontend/public/service-worker.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/frontend/public/service-worker.js b/frontend/public/service-worker.js index 86ea725..6887f86 100644 --- a/frontend/public/service-worker.js +++ b/frontend/public/service-worker.js @@ -1,10 +1,10 @@ -const CACHE_NAME = 'erp-shell-v2'; +const CACHE_NAME = 'erp-shell-v3'; const API_CACHE_NAME = 'erp-api-v1'; const WRITE_QUEUE_DB_NAME = 'erp-write-queue-db'; const WRITE_QUEUE_STORE = 'requests'; const WRITE_QUEUE_SYNC_TAG = 'erp-write-queue-sync'; const OFFLINE_URL = '/offline.html'; -const PRECACHE_URLS = ['/', '/index.html', '/manifest.webmanifest', '/pwa-icon.svg', OFFLINE_URL]; +const PRECACHE_URLS = ['/', '/manifest.webmanifest', '/pwa-icon.svg', OFFLINE_URL]; const API_CACHE_BLOCKLIST = [ '/api/token/', @@ -143,9 +143,27 @@ async function replayQueuedRequests() { } self.addEventListener('install', (event) => { - event.waitUntil( - caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE_URLS)) +self.addEventListener('install', (event) => { +async function precacheShell() { + const cache = await caches.open(CACHE_NAME); + await Promise.all( + PRECACHE_URLS.map(async (url) => { + try { + const response = await fetch(url, { cache: 'reload' }); + if (!response || !response.ok) { + console.warn('Skipping precache for non-OK response:', url, response && response.status); + return; + } + await cache.put(url, response); + } catch (error) { + console.warn('Skipping precache for failed request:', url, error); + } + }) ); +} + +self.addEventListener('install', (event) => { + event.waitUntil(precacheShell()); self.skipWaiting(); });