feat(pwa): add auto-update on reopen, live tickers, and manual refresh to dashboards

This commit is contained in:
Moritz Graf
2026-10-11 22:25:37 +02:00
parent 63497765b0
commit e9d2c59eed
3 changed files with 225 additions and 9 deletions
+12 -3
View File
@@ -1,5 +1,5 @@
// Minimal service worker for Mila PWA installability & offline resilience
const CACHE_NAME = 'mila-v1';
// Minimal service worker for Family PWAs (Mila & Moritz) with instant cache-bypassing navigation
const CACHE_NAME = 'family-pwa-v2';
self.addEventListener('install', (event) => {
self.skipWaiting();
@@ -19,7 +19,16 @@ self.addEventListener('activate', (event) => {
self.addEventListener('fetch', (event) => {
if (event.request.method !== 'GET') return;
// Network-first strategy: Always fetch live real-time updates from MinIO
// For HTML documents/navigations: ALWAYS bypass HTTP cache to get latest live server rendering
if (event.request.destination === 'document' || event.request.mode === 'navigate') {
event.respondWith(
fetch(event.request, { cache: 'no-cache' }).catch(() => caches.match(event.request))
);
return;
}
// Assets (images, fonts, scripts): network-first with offline cache fallback
event.respondWith(
fetch(event.request).catch(() => caches.match(event.request))
);