From d196b8b9293532c7bd06a8d63d07b742231d8d53 Mon Sep 17 00:00:00 2001 From: torsten Date: Sat, 31 Oct 2026 15:12:16 +0100 Subject: [PATCH] Statische Dateien eine Woche cachen und Team-Logos lazy laden --- README.md | 8 ++++++++ tippspiel/src/Views/admin/rounds.php | 4 ++-- tippspiel/src/Views/ranking.php | 4 ++-- tippspiel/src/Views/round.php | 4 ++-- tippspiel/src/Views/tipps/game.php | 4 ++-- tippspiel/src/Views/tipps/index.php | 4 ++-- tippspiel/src/Views/tipps/round.php | 4 ++-- tools/deploy_live.py | 14 ++++++++++++++ 8 files changed, 34 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4d74a04..2ae3c36 100644 --- a/README.md +++ b/README.md @@ -345,6 +345,14 @@ mysql -h -u -p < tools/dumps/tippspiel_live_<...>.sql ohne diesen Zwischenschritt würde `STOR` die Zieldatei erst leeren, und ein Request in genau diesem Moment bekäme bei `index.php` einen Parse-Fehler (500). Das Staging-Verzeichnis wird nach dem Deploy entfernt, sofern es leer ist. +- **Cache-Header:** Die `.htaccess` setzt für Bilder, CSS und Fonts + `Cache-Control: public, max-age=604800` (7 Tage); `sw.js` bekommt `no-cache`, + damit App-Updates nicht im Browser hängen. Ohne diese Header fragt der Browser + bei jedem Seitenaufruf erneut nach (304) – Bilder sind ~66 % aller Requests + und ~94 % des Traffics. +- **Bilder nur bei Änderung hochladen:** `--skip-img-upload` verwenden, wenn + `public/img/` unverändert ist. 230 Dateien neu zu schreiben kostet nur Zeit + und setzt die Änderungszeitpunkte neu. - Beim DB-Sync werden nach dem Import die Zeilenzahlen aller Tabellen geprüft. ## Nützliche Befehle diff --git a/tippspiel/src/Views/admin/rounds.php b/tippspiel/src/Views/admin/rounds.php index d1b38e8..a55be17 100644 --- a/tippspiel/src/Views/admin/rounds.php +++ b/tippspiel/src/Views/admin/rounds.php @@ -98,9 +98,9 @@ $teamLogo = function ($name) { $l2 = $teamLogo($team2Name); ?> - - diff --git a/tippspiel/src/Views/ranking.php b/tippspiel/src/Views/ranking.php index 7b46bd9..9007d7b 100644 --- a/tippspiel/src/Views/ranking.php +++ b/tippspiel/src/Views/ranking.php @@ -224,11 +224,11 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR $matchTitle = htmlspecialchars($game['team1'] . ' : ' . $game['team2']); ?> - + - + diff --git a/tippspiel/src/Views/round.php b/tippspiel/src/Views/round.php index 4865cf5..3a7a076 100644 --- a/tippspiel/src/Views/round.php +++ b/tippspiel/src/Views/round.php @@ -38,9 +38,9 @@ $teamLogo = function ($name) { Spieler - +
- +
() diff --git a/tippspiel/src/Views/tipps/game.php b/tippspiel/src/Views/tipps/game.php index 19e5dd8..39feec1 100644 --- a/tippspiel/src/Views/tipps/game.php +++ b/tippspiel/src/Views/tipps/game.php @@ -21,9 +21,9 @@ $teamLogo = function ($name) {
Maximale Anzahl gleicher Joker:

- + : - +

diff --git a/tippspiel/src/Views/tipps/index.php b/tippspiel/src/Views/tipps/index.php index e573353..edf9485 100644 --- a/tippspiel/src/Views/tipps/index.php +++ b/tippspiel/src/Views/tipps/index.php @@ -49,9 +49,9 @@ $teamLogo = function ($name) { ?> - + : - + -1 ? (int)$game['score1'] . ' : ' . (int)$game['score2'] : ''; ?> diff --git a/tippspiel/src/Views/tipps/round.php b/tippspiel/src/Views/tipps/round.php index 7934253..d56f3ae 100644 --- a/tippspiel/src/Views/tipps/round.php +++ b/tippspiel/src/Views/tipps/round.php @@ -34,9 +34,9 @@ $teamLogo = function ($name) { $gameId = (int)$game['id']; ?> - + : - + diff --git a/tools/deploy_live.py b/tools/deploy_live.py index 82efa94..f3b5e1f 100755 --- a/tools/deploy_live.py +++ b/tools/deploy_live.py @@ -156,6 +156,20 @@ def build_htaccess(creds, app_url): "RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]", "", "", + "", + " # Statische Dateien eine Woche cachen. Ohne diese Zeilen fragt der", + " # Browser bei jedem Seitenaufruf erneut nach (304) - Bilder sind", + " # der groesste Traffic-Posten (siehe docs/betriebsdiagnose.md).", + " ", + " Header set Cache-Control \"public, max-age=604800\"", + " ", + " # Der Service Worker steuert die App-Updates und darf nicht lange", + " # im Cache haengen, sonst bleiben Aenderungen tagelang unsichtbar.", + " ", + " Header set Cache-Control \"no-cache\"", + " ", + "", + "", ] for name in HTACCESS_ORDER: if values.get(name):