fix: recover old GTIN service worker caches

This commit is contained in:
desfoto automation
2026-09-25 20:08:25 +02:00
parent de6de3c6c4
commit 5e7fa9be05
11 changed files with 140 additions and 3 deletions

View File

@@ -92,12 +92,13 @@ fi
printf '\n== routes\n' printf '\n== routes\n'
for route in / /fotografie/ /businessfotografie/ /portrait-und-model/ /familie/ \ for route in / /fotografie/ /businessfotografie/ /portrait-und-model/ /familie/ \
/minishootings/ /video/ /musik-und-buehne/ /social-media/ /projekte/ /ueber/ /kontakt/ /impressum/ /datenschutz/ \ /minishootings/ /video/ /musik-und-buehne/ /social-media/ /projekte/ /ueber/ /kontakt/ /impressum/ /datenschutz/ \
/gtin/ /gtin/impressum/ /gtin/datenschutz/; do /gtin/ /gtin/impressum/ /gtin/datenschutz/ /gtin/aktualisieren/; do
check_status "$base$route" 200 check_status "$base$route" 200
done done
check_redirect "$base/gtin" "$base/gtin/" check_redirect "$base/gtin" "$base/gtin/"
check_redirect "$base/gtin/impressum" "$base/gtin/impressum/" check_redirect "$base/gtin/impressum" "$base/gtin/impressum/"
check_redirect "$base/gtin/datenschutz" "$base/gtin/datenschutz/" check_redirect "$base/gtin/datenschutz" "$base/gtin/datenschutz/"
check_redirect "$base/gtin/aktualisieren" "$base/gtin/aktualisieren/"
# The retired photo URL must keep working: it is the umbrella page now. # The retired photo URL must keep working: it is the umbrella page now.
check_redirect "$base/shootings" "$base/fotografie/" check_redirect "$base/shootings" "$base/fotografie/"
@@ -156,6 +157,8 @@ check_contains "$base/gtin/datenschutz/" "Cache API"
check_contains "$base/gtin/datenschutz/" "nicht an einen Server übertragen" check_contains "$base/gtin/datenschutz/" "nicht an einen Server übertragen"
check_contains "$base/gtin/datenschutz/" 'name="robots" content="noindex, nofollow"' check_contains "$base/gtin/datenschutz/" 'name="robots" content="noindex, nofollow"'
check_contains "$base/gtin/impressum/" 'name="robots" content="noindex, nofollow"' check_contains "$base/gtin/impressum/" 'name="robots" content="noindex, nofollow"'
check_contains "$base/gtin/aktualisieren/" 'name="robots" content="noindex, nofollow"'
check_status "$base/gtin/js/aktualisieren.js" 200
for route in / /fotografie/ /businessfotografie/ /portrait-und-model/ /familie/ \ for route in / /fotografie/ /businessfotografie/ /portrait-und-model/ /familie/ \
/minishootings/ /video/ /musik-und-buehne/ /social-media/ /projekte/ /ueber/ \ /minishootings/ /video/ /musik-und-buehne/ /social-media/ /projekte/ /ueber/ \
/kontakt/ /impressum/ /datenschutz/; do /kontakt/ /impressum/ /datenschutz/; do

View File

@@ -95,7 +95,8 @@ them is a defect, not a style question:
to a server. Its `/gtin/impressum/` and `/gtin/datenschutz/` pages are to a server. Its `/gtin/impressum/` and `/gtin/datenschutz/` pages are
standalone, unlisted legal pages. The tool stays unlisted: no main-site standalone, unlisted legal pages. The tool stays unlisted: no main-site
navigation or page links, no sitemap entry, and `noindex,nofollow`; only the navigation or page links, no sitemap entry, and `noindex,nofollow`; only the
tool links to its own legal pages, which never link back to the main site; GTIN area links to its own legal pages, which never link back to the main site.
The unlisted `/gtin/aktualisieren/` page repairs old redirected app caches;
- `access_log off` in `nginx.conf` — never enable request logging; - `access_log off` in `nginx.conf` — never enable request logging;
- `error_log /dev/null crit;` in `nginx.conf` — never write an error-log file either; - `error_log /dev/null crit;` in `nginx.conf` — never write an error-log file either;
- fonts, scripts, styles and images are served from this origin only; - fonts, scripts, styles and images are served from this origin only;

View File

@@ -71,6 +71,8 @@ Werkzeug selbst verlinkt auf seine eigenständigen Rechtstexte unter `/gtin/impr
`/gtin/` ohne Weiterleitung; jede Änderung am Werkzeug erhält eine neue `/gtin/` ohne Weiterleitung; jede Änderung am Werkzeug erhält eine neue
Cache-Version. Die eigenständige Datenschutzerklärung liegt unter Cache-Version. Die eigenständige Datenschutzerklärung liegt unter
`/gtin/datenschutz/`; die Rechtstexte sind nicht mit denen des Hauptauftritts verknüpft. `/gtin/datenschutz/`; die Rechtstexte sind nicht mit denen des Hauptauftritts verknüpft.
Der unverlinkte Pfad `/gtin/aktualisieren/` entfernt eine fehlerhafte
Startantwort aus älteren Browser-Caches und öffnet das Werkzeug danach erneut.
## Herkunft der Inhalte ## Herkunft der Inhalte

View File

@@ -67,6 +67,7 @@ server {
location = /gtin { return 301 /gtin/; } location = /gtin { return 301 /gtin/; }
location = /gtin/impressum { return 301 /gtin/impressum/; } location = /gtin/impressum { return 301 /gtin/impressum/; }
location = /gtin/datenschutz { return 301 /gtin/datenschutz/; } location = /gtin/datenschutz { return 301 /gtin/datenschutz/; }
location = /gtin/aktualisieren { return 301 /gtin/aktualisieren/; }
location = /gtin/manifest.webmanifest { location = /gtin/manifest.webmanifest {
default_type application/manifest+json; default_type application/manifest+json;
try_files $uri =404; try_files $uri =404;

View File

@@ -45,6 +45,7 @@ UNLISTED_HTML = [
"gtin/index.html", "gtin/index.html",
"gtin/impressum/index.html", "gtin/impressum/index.html",
"gtin/datenschutz/index.html", "gtin/datenschutz/index.html",
"gtin/aktualisieren/index.html",
] ]
INK = (23, 20, 15) INK = (23, 20, 15)

View 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>

View 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.';
});

View File

@@ -10,7 +10,7 @@
const sw = /** @type {ServiceWorkerGlobalScope} */ (/** @type {unknown} */ (self)); const sw = /** @type {ServiceWorkerGlobalScope} */ (/** @type {unknown} */ (self));
const CACHE_VERSION = '403b5842d1cd'; const CACHE_VERSION = '76462b4916fd';
const CACHE_PREFIX = 'desfoto-gtin-generator-'; const CACHE_PREFIX = 'desfoto-gtin-generator-';
const CACHE_NAME = `${CACHE_PREFIX}${CACHE_VERSION}`; const CACHE_NAME = `${CACHE_PREFIX}${CACHE_VERSION}`;

View 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>

View 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.';
});

View File

@@ -56,6 +56,7 @@ class BuildLayout(unittest.TestCase):
"gtin/index.html", "gtin/index.html",
"gtin/impressum/index.html", "gtin/impressum/index.html",
"gtin/datenschutz/index.html", "gtin/datenschutz/index.html",
"gtin/aktualisieren/index.html",
} }
actual = {str(f.relative_to(SITE)) for f in SITE.rglob("*.html")} actual = {str(f.relative_to(SITE)) for f in SITE.rglob("*.html")}
self.assertEqual(expected, actual) self.assertEqual(expected, actual)