From 9aa3532dd67c0923685006105f8231aab6fca7d0 Mon Sep 17 00:00:00 2001 From: nessi Date: Fri, 6 Feb 2026 12:20:52 +0100 Subject: [PATCH] Enable immediate PWA updates and cache cleanup. Added functionality to immediately activate new Service Worker versions and reload the page upon updates. Enhanced caching configuration in Vite to clean outdated caches and ensure clients use the latest version. --- frontend/src/main.jsx | 7 +++++++ frontend/vite.config.js | 3 +++ 2 files changed, 10 insertions(+) diff --git a/frontend/src/main.jsx b/frontend/src/main.jsx index 76a1787..19def02 100644 --- a/frontend/src/main.jsx +++ b/frontend/src/main.jsx @@ -5,3 +5,10 @@ import { registerSW } from "virtual:pwa-register"; createRoot(document.getElementById("root")).render(); registerSW({ immediate: true }); +const updateSW = registerSW({ + immediate: true, + onNeedRefresh() { + updateSW(true); // sofort neue Version aktivieren + window.location.reload(); + }, + }); diff --git a/frontend/vite.config.js b/frontend/vite.config.js index ef03953..d23be78 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -28,6 +28,9 @@ export default defineConfig({ workbox: { // Caching-Default: die App-Shell wird offline verfügbar globPatterns: ["**/*.{js,css,html,ico,png,jpg,jpeg,svg,webp}"], + cleanupOutdatedCaches: true, + skipWaiting: true, + clientsClaim: true, } }) ]