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.
This commit is contained in:
@@ -5,3 +5,10 @@ import { registerSW } from "virtual:pwa-register";
|
||||
|
||||
createRoot(document.getElementById("root")).render(<App />);
|
||||
registerSW({ immediate: true });
|
||||
const updateSW = registerSW({
|
||||
immediate: true,
|
||||
onNeedRefresh() {
|
||||
updateSW(true); // sofort neue Version aktivieren
|
||||
window.location.reload();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
})
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user