From a1e5364f25ed6f9a1b69cd2a4c3ab5d6589df664 Mon Sep 17 00:00:00 2001 From: rene Date: Fri, 8 May 2026 11:27:06 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20iOS=20bfcache=20=E2=80=94=20=3F=5Ft=3Dti?= =?UTF-8?q?mestamp=20bei=20Update-Reload,=20wird=20sofort=20aus=20URL=20en?= =?UTF-8?q?tfernt=20(SW=20by-v770)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/main.py | 2 +- backend/static/index.html | 5 ++--- backend/static/js/app.js | 8 +++++--- backend/static/js/pages/settings.js | 4 ++-- backend/static/sw.js | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/backend/main.py b/backend/main.py index 8ab8c91..64e5cb4 100644 --- a/backend/main.py +++ b/backend/main.py @@ -327,7 +327,7 @@ MEDIA_DIR = os.getenv("MEDIA_DIR", "/data/media") os.makedirs(MEDIA_DIR, exist_ok=True) app.mount("/media", StaticFiles(directory=MEDIA_DIR), name="media") -APP_VER = "769" # muss mit APP_VER in app.js übereinstimmen +APP_VER = "770" # muss mit APP_VER in app.js übereinstimmen @app.get("/api/version") async def app_version(): diff --git a/backend/static/index.html b/backend/static/index.html index 9c3a025..b7990ef 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -578,7 +578,7 @@ - + @@ -640,8 +640,7 @@ // Wenn neuer SW die Kontrolle übernimmt → Seite neu laden navigator.serviceWorker.addEventListener('controllerchange', () => { - // location.replace statt reload() — bypassed iOS bfcache - window.location.replace(window.location.href); + window.location.replace('/?_t=' + Date.now()); }); navigator.serviceWorker.addEventListener('message', e => { diff --git a/backend/static/js/app.js b/backend/static/js/app.js index 68ee474..83d1b7c 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,9 +3,11 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '769'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '770'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.5.0'; // ← semantische Version, wird bei make release gesetzt const IS_STAGING = location.hostname === 'staging.banyaro.app'; +// Cache-Bust-Parameter nach Update-Reload sofort entfernen +if (location.search.includes('_t=')) history.replaceState(null, '', '/'); const App = (() => { @@ -1037,8 +1039,8 @@ const App = (() => { btn.textContent = 'Lädt…'; btn.disabled = true; sessionStorage.setItem('by_update_reload', APP_VER); - // Immer zur Root — location.href enthält ggf. Hash der App in alten Zustand navigiert - setTimeout(() => location.replace('/'), 800); + // ?_t= Timestamp zwingt iOS bfcache zur Aufgabe — wird beim Start sofort entfernt + setTimeout(() => location.replace('/?_t=' + Date.now()), 800); try { const reg = await navigator.serviceWorker?.getRegistration(); if (reg?.waiting) reg.waiting.postMessage({ type: 'SKIP_WAITING' }); diff --git a/backend/static/js/pages/settings.js b/backend/static/js/pages/settings.js index dbb2589..bc2fd40 100644 --- a/backend/static/js/pages/settings.js +++ b/backend/static/js/pages/settings.js @@ -764,11 +764,11 @@ window.Page_settings = (() => { if (serverVersion && serverVersion !== localVersion) { if (reg?.waiting) reg.waiting.postMessage({ type: 'SKIP_WAITING' }); UI.toast.info(`Update auf v${serverVersion} — Seite wird neu geladen…`); - setTimeout(() => location.replace('/'), 1500); + setTimeout(() => location.replace('/?_t=' + Date.now()), 1500); } else if (reg?.waiting) { reg.waiting.postMessage({ type: 'SKIP_WAITING' }); UI.toast.success('Update wird installiert…'); - setTimeout(() => location.replace('/'), 1500); + setTimeout(() => location.replace('/?_t=' + Date.now()), 1500); } else { UI.toast.success(`Ban Yaro ist aktuell — Build ${localVersion}`); } diff --git a/backend/static/sw.js b/backend/static/sw.js index 42e7a1e..fcd9789 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -3,7 +3,7 @@ Offline-Cache + Push Notifications + Tile-Cache ============================================================ */ -const CACHE_VERSION = 'by-v769'; +const CACHE_VERSION = 'by-v770'; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten const CACHE_API = 'ban-yaro-api-v1'; // API-Response-Cache