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
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue