Fix: Force-Update Cooldown + robusteres Cache-Clear, SW by-v1105
Symptom: 'Einen Moment, wir besorgen neue Leckerlis' Loading-Screen erscheint beim User wiederholt beim Wechsel in andere Bereiche. Ursachen: 1. In dieser Session wurden viele Bumps in kurzer Zeit ausgerollt (1100 → 1104). Jeder Versions-Mismatch zwischen App-Cache und Server triggert force-update. 2. /force-update Cache-Delete war fire-and-forget mit nur 1.5s Reload-Timer — auf iOS-PWA oft zu kurz für asynchrone unregister/ caches.delete, daher landete der Reload manchmal noch im alten Cache-Stand → erneuter Mismatch → erneuter force-update. Fixes: - app.js: Cooldown 5 Min nach force-update — verhindert Loop bei mehrfachen schnellen Bumps. Mismatch wird erkannt aber nicht mehr sofort reagiert. - /force-update: async/await für SW-Unregister + Cache-Delete bevor Reload. Safety-Timeout 4s. Reload-URL mit ?_t= Cache-Bust.
This commit is contained in:
parent
9a066cb24c
commit
b0ae71ba69
6 changed files with 43 additions and 25 deletions
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
|||
1104
|
||||
1105
|
||||
|
|
@ -1770,12 +1770,25 @@ p{color:#94a3b8;font-size:14px}</style></head>
|
|||
<script>
|
||||
// Zweiten Reload durch SW-updatefound verhindern
|
||||
sessionStorage.setItem('by_skip_sw_reload','1');
|
||||
// Fire-and-forget — kein await, Reload nach spätestens 1.5s
|
||||
try{
|
||||
navigator.serviceWorker?.getRegistrations().then(r=>r.forEach(s=>s.unregister())).catch(()=>{});
|
||||
caches.keys().then(k=>k.forEach(c=>caches.delete(c))).catch(()=>{});
|
||||
}catch(e){}
|
||||
setTimeout(()=>location.replace('/'),1500);
|
||||
// Warten bis SW-Unregister + Cache-Delete WIRKLICH durch sind (await),
|
||||
// dann mit Cache-Bust reloaden. Hard-Timeout 4s als Sicherheitsnetz.
|
||||
(async () => {
|
||||
const reload = () => location.replace('/?_t=' + Date.now());
|
||||
const safety = setTimeout(reload, 4000);
|
||||
try {
|
||||
const tasks = [];
|
||||
if (navigator.serviceWorker) {
|
||||
tasks.push(navigator.serviceWorker.getRegistrations()
|
||||
.then(r => Promise.all(r.map(s => s.unregister().catch(() => {})))));
|
||||
}
|
||||
tasks.push(caches.keys()
|
||||
.then(k => Promise.all(k.map(c => caches.delete(c).catch(() => {})))));
|
||||
await Promise.all(tasks);
|
||||
} catch (e) {}
|
||||
clearTimeout(safety);
|
||||
// Kurzes Delay damit der Browser die Storage-Operationen committet
|
||||
setTimeout(reload, 300);
|
||||
})();
|
||||
</script></body></html>"""
|
||||
return HTMLResponse(content=html, headers={"Cache-Control": "no-store"})
|
||||
|
||||
|
|
|
|||
|
|
@ -86,14 +86,14 @@
|
|||
<title>Ban Yaro</title>
|
||||
|
||||
<!-- Theme + theme-color Statusleiste vor CSS setzen -->
|
||||
<script src="/js/boot-early.js?v=1104"></script>
|
||||
<script src="/js/boot-early.js?v=1105"></script>
|
||||
|
||||
<!-- CSS: Reihenfolge ist wichtig — ?v= zwingt Browser zur Neuladung -->
|
||||
<link rel="stylesheet" href="/css/design-system.css?v=1104">
|
||||
<link rel="stylesheet" href="/css/layout.css?v=1104">
|
||||
<link rel="stylesheet" href="/css/components.css?v=1104">
|
||||
<link rel="stylesheet" href="/css/utilities.css?v=1104">
|
||||
<link rel="stylesheet" href="/css/lists.css?v=1104">
|
||||
<link rel="stylesheet" href="/css/design-system.css?v=1105">
|
||||
<link rel="stylesheet" href="/css/layout.css?v=1105">
|
||||
<link rel="stylesheet" href="/css/components.css?v=1105">
|
||||
<link rel="stylesheet" href="/css/utilities.css?v=1105">
|
||||
<link rel="stylesheet" href="/css/lists.css?v=1105">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
|
@ -617,11 +617,11 @@
|
|||
<div id="modal-container"></div>
|
||||
|
||||
<!-- JS: Reihenfolge ist wichtig — erst Basis, dann Features -->
|
||||
<script src="/js/api.js?v=1104"></script>
|
||||
<script src="/js/ui.js?v=1104"></script>
|
||||
<script src="/js/app.js?v=1104"></script>
|
||||
<script src="/js/worlds.js?v=1104"></script>
|
||||
<script src="/js/offline-indicator.js?v=1104"></script>
|
||||
<script src="/js/api.js?v=1105"></script>
|
||||
<script src="/js/ui.js?v=1105"></script>
|
||||
<script src="/js/app.js?v=1105"></script>
|
||||
<script src="/js/worlds.js?v=1105"></script>
|
||||
<script src="/js/offline-indicator.js?v=1105"></script>
|
||||
|
||||
<!-- Feature-Seiten werden lazy geladen -->
|
||||
|
||||
|
|
@ -631,7 +631,7 @@
|
|||
|
||||
|
||||
<!-- Boot: Offline-Banner + SW-Registration (extrahiert für CSP) -->
|
||||
<script src="/js/boot.js?v=1104"></script>
|
||||
<script src="/js/boot.js?v=1105"></script>
|
||||
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
Router, State-Management, Navigation, Initialisierung.
|
||||
============================================================ */
|
||||
|
||||
const APP_VER = '1104'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VER = '1105'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
|
||||
const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt
|
||||
window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator)
|
||||
window.APP_VERSION = APP_VERSION;
|
||||
|
|
@ -129,16 +129,21 @@ const App = (() => {
|
|||
function navigate(pageId, pushHistory = true, params = {}) {
|
||||
if (!pages[pageId]) return;
|
||||
// Neue Version erkannt → nur aktualisieren wenn kein Bearbeitungsfenster offen ist
|
||||
// UND wenn nicht erst kürzlich force-update lief (Cooldown 5 Min) — verhindert Loop
|
||||
// bei mehreren schnellen Deploys oder iOS-PWA-Cache-Quirks.
|
||||
if (window._byUpdatePending) {
|
||||
const modalOpen = document.querySelector('#modal-container .modal-overlay') !== null;
|
||||
if (!modalOpen) {
|
||||
const lastForce = parseInt(sessionStorage.getItem('by_last_force_update') || '0', 10);
|
||||
const cooldownActive = (Date.now() - lastForce) < 5 * 60 * 1000;
|
||||
if (!modalOpen && !cooldownActive) {
|
||||
window._byUpdatePending = false;
|
||||
sessionStorage.setItem('by_updated_to', window._byNewVersion || '');
|
||||
sessionStorage.setItem('by_update_target', pageId); // Zielseite nach Update
|
||||
sessionStorage.setItem('by_update_target', pageId);
|
||||
sessionStorage.setItem('by_last_force_update', String(Date.now()));
|
||||
location.href = '/force-update';
|
||||
return;
|
||||
}
|
||||
// Modal offen → beim nächsten Seitenwechsel versuchen
|
||||
// Modal offen oder Cooldown → bei nächstem Seitenwechsel versuchen
|
||||
}
|
||||
if (window.Worlds?._visible) window.Worlds.hide();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<script src="/js/landing-init.js?v=1104"></script>
|
||||
<script src="/js/landing-init.js?v=1105"></script>
|
||||
<title>Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz</title>
|
||||
<meta name="description" content="Ban Yaro: Die kostenlose All-in-One Hunde-App für DACH. Tagebuch, Giftköder-Alarm, Training mit KI, Forum, Wurfbörse, Stammbaum, Inzucht-Check — DSGVO-konform, offline-fähig, ohne App Store.">
|
||||
<meta name="keywords" content="Hunde App, Hunde Community, Wurfbörse, Züchter, Welpen kaufen, Stammbaum Hund, Inzuchtkoeffizient, Hundezucht, Impfpass Hund, Giftköder Alarm, Gassi Community, Hundetraining App, Hunde Forum, Hunde KI, Hundefilm Datenbank, Welpen Marktplatz">
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
============================================================ */
|
||||
|
||||
// ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab
|
||||
const VER = '1104';
|
||||
const VER = '1105';
|
||||
const CACHE_VERSION = `by-v${VER}`;
|
||||
const CACHE_STATIC = `${CACHE_VERSION}-static`;
|
||||
const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue