feat(pwa): add auto-update on reopen, live tickers, and manual refresh to dashboards
This commit is contained in:
@@ -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))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user