fix: recover old GTIN service worker caches
This commit is contained in:
31
site/gtin/aktualisieren/index.html
Normal file
31
site/gtin/aktualisieren/index.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>GTIN aktualisieren</title>
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<link rel="canonical" href="https://desfoto.de/gtin/aktualisieren/" />
|
||||
<link rel="icon" href="/gtin/icons/favicon.svg" type="image/svg+xml" />
|
||||
<style>
|
||||
:root { color-scheme: light; font: 16px/1.65 system-ui, sans-serif; color: #202124; background: #fff; }
|
||||
body { box-sizing: border-box; max-width: 42rem; margin: 0 auto; padding: 2.5rem 1.25rem; }
|
||||
h1 { margin: 0 0 1.5rem; font-size: clamp(2rem, 7vw, 3rem); line-height: 1.1; }
|
||||
a { color: #174ea6; }
|
||||
footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid #ddd; }
|
||||
footer a + a { margin-left: 1rem; }
|
||||
</style>
|
||||
<script src="/gtin/js/aktualisieren.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>GTIN aktualisieren</h1>
|
||||
<p id="status" role="status">Das Werkzeug wird aktualisiert. Du wirst gleich weitergeleitet.</p>
|
||||
<p><a href="/gtin/">GTIN-Werkzeug öffnen</a></p>
|
||||
</main>
|
||||
<footer>
|
||||
<a href="/gtin/impressum/">Impressum</a>
|
||||
<a href="/gtin/datenschutz/">Datenschutz</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
33
site/gtin/js/aktualisieren.js
Normal file
33
site/gtin/js/aktualisieren.js
Normal file
@@ -0,0 +1,33 @@
|
||||
/* Entfernt die umgeleitete Startantwort aus frueheren GTIN-Caches. */
|
||||
|
||||
const status = document.querySelector('#status');
|
||||
const appUrl = new URL('../', window.location.href);
|
||||
const alterIndex = new URL('index.html', appUrl).href;
|
||||
|
||||
async function aktualisiereWerkzeug() {
|
||||
if ('caches' in window) {
|
||||
const namen = await caches.keys();
|
||||
for (const name of namen) {
|
||||
if (!name.startsWith('desfoto-gtin-generator-')) continue;
|
||||
const cache = await caches.open(name);
|
||||
const antwort = await cache.match(alterIndex);
|
||||
if (antwort?.redirected) await cache.delete(alterIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if ('serviceWorker' in navigator) {
|
||||
const registrierung = await navigator.serviceWorker.getRegistration(appUrl.href);
|
||||
if (registrierung) {
|
||||
await Promise.race([
|
||||
registrierung.update().catch(() => undefined),
|
||||
new Promise((resolve) => window.setTimeout(resolve, 5000)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
window.location.replace(appUrl.href);
|
||||
}
|
||||
|
||||
aktualisiereWerkzeug().catch(() => {
|
||||
status.textContent = 'Die Aktualisierung ist fehlgeschlagen. Bitte lösche die Website-Daten für desfoto.de in deinem Browser und öffne das Werkzeug erneut.';
|
||||
});
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
const sw = /** @type {ServiceWorkerGlobalScope} */ (/** @type {unknown} */ (self));
|
||||
|
||||
const CACHE_VERSION = '403b5842d1cd';
|
||||
const CACHE_VERSION = '76462b4916fd';
|
||||
const CACHE_PREFIX = 'desfoto-gtin-generator-';
|
||||
const CACHE_NAME = `${CACHE_PREFIX}${CACHE_VERSION}`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user