From b0ae71ba69ba3736a8eae44d6c50f58aca4d0633 Mon Sep 17 00:00:00 2001 From: rene Date: Wed, 27 May 2026 07:51:36 +0200 Subject: [PATCH] Fix: Force-Update Cooldown + robusteres Cache-Clear, SW by-v1105 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- VERSION | 2 +- backend/main.py | 25 +++++++++++++++++++------ backend/static/index.html | 24 ++++++++++++------------ backend/static/js/app.js | 13 +++++++++---- backend/static/landing.html | 2 +- backend/static/sw.js | 2 +- 6 files changed, 43 insertions(+), 25 deletions(-) diff --git a/VERSION b/VERSION index 5afb033..2b48a28 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1104 \ No newline at end of file +1105 \ No newline at end of file diff --git a/backend/main.py b/backend/main.py index b6beb40..b409706 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1770,12 +1770,25 @@ p{color:#94a3b8;font-size:14px} """ return HTMLResponse(content=html, headers={"Cache-Control": "no-store"}) diff --git a/backend/static/index.html b/backend/static/index.html index 846078e..0efb61d 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -617,11 +617,11 @@ - - - - - + + + + + @@ -631,7 +631,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 514e893..fa2432e 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -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(); diff --git a/backend/static/landing.html b/backend/static/landing.html index dccab59..8616190 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -4,7 +4,7 @@ - + Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz diff --git a/backend/static/sw.js b/backend/static/sw.js index 4f7215b..0bbb83e 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -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