Statische Dateien eine Woche cachen und Team-Logos lazy laden
This commit is contained in:
parent
9bc5e5b905
commit
d196b8b929
8 changed files with 34 additions and 12 deletions
|
|
@ -345,6 +345,14 @@ mysql -h <host> -u <user> -p <datenbank> < 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
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ $teamLogo = function ($name) {
|
|||
$l2 = $teamLogo($team2Name);
|
||||
?>
|
||||
<tr>
|
||||
<td><span class="team-cell"><?php if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo"><?php endif; ?><input type="text" name="<?php echo $field; ?>[team1]" maxlength="100" required
|
||||
<td><span class="team-cell"><?php if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?><input type="text" name="<?php echo $field; ?>[team1]" maxlength="100" required
|
||||
value="<?php echo htmlspecialchars($team1Name); ?>"></span></td>
|
||||
<td><span class="team-cell"><?php if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo"><?php endif; ?><input type="text" name="<?php echo $field; ?>[team2]" maxlength="100" required
|
||||
<td><span class="team-cell"><?php if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?><input type="text" name="<?php echo $field; ?>[team2]" maxlength="100" required
|
||||
value="<?php echo htmlspecialchars($team2Name); ?>"></span></td>
|
||||
<td><input type="datetime-local" name="<?php echo $field; ?>[kickoff]" required
|
||||
value="<?php echo htmlspecialchars($in['kickoff'] ?? date('Y-m-d\TH:i', strtotime($game['kickoff']))); ?>"></td>
|
||||
|
|
|
|||
|
|
@ -224,11 +224,11 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
|
|||
$matchTitle = htmlspecialchars($game['team1'] . ' : ' . $game['team2']);
|
||||
?>
|
||||
<th class="game-header" title="<?php echo $matchTitle; ?>">
|
||||
<?php if ($t1 && $t1['logo']): ?><img src="<?php echo htmlspecialchars($t1['logo']); ?>" alt="" class="team-logo"><?php endif; ?>
|
||||
<?php if ($t1 && $t1['logo']): ?><img src="<?php echo htmlspecialchars($t1['logo']); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?>
|
||||
<span class="rotated-label"><?php echo htmlspecialchars($game['team1']); ?></span>
|
||||
</th>
|
||||
<th class="game-header" title="<?php echo $matchTitle; ?>">
|
||||
<?php if ($t2 && $t2['logo']): ?><img src="<?php echo htmlspecialchars($t2['logo']); ?>" alt="" class="team-logo"><?php endif; ?>
|
||||
<?php if ($t2 && $t2['logo']): ?><img src="<?php echo htmlspecialchars($t2['logo']); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?>
|
||||
<span class="rotated-label"><?php echo htmlspecialchars($game['team2']); ?></span>
|
||||
</th>
|
||||
<th class="game-header" title="Joker">
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ $teamLogo = function ($name) {
|
|||
<th>Spieler</th>
|
||||
<?php foreach ($round['games'] as $game): ?>
|
||||
<th class="game-header">
|
||||
<?php $l1 = $teamLogo($game['team1']); if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo"><?php endif; ?>
|
||||
<?php $l1 = $teamLogo($game['team1']); if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?>
|
||||
<?php echo htmlspecialchars($game['team1']); ?><br>
|
||||
<?php $l2 = $teamLogo($game['team2']); if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo"><?php endif; ?>
|
||||
<?php $l2 = $teamLogo($game['team2']); if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?>
|
||||
<?php echo htmlspecialchars($game['team2']); ?><br>
|
||||
<small>(<?php echo Game::getResultString($game['score1'], $game['score2'], $game['kickoff']); ?>)</small>
|
||||
</th>
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ $teamLogo = function ($name) {
|
|||
<div>Maximale Anzahl gleicher Joker: <?php echo $maxIdenticalJokertipps; ?></div>
|
||||
|
||||
<p><strong>
|
||||
<span class="team-cell"><?php $l1 = $teamLogo($game['team1']); if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo"><?php endif; ?><?php echo htmlspecialchars($game['team1']); ?></span>
|
||||
<span class="team-cell"><?php $l1 = $teamLogo($game['team1']); if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?><?php echo htmlspecialchars($game['team1']); ?></span>
|
||||
:
|
||||
<span class="team-cell"><?php $l2 = $teamLogo($game['team2']); if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo"><?php endif; ?><?php echo htmlspecialchars($game['team2']); ?></span>
|
||||
<span class="team-cell"><?php $l2 = $teamLogo($game['team2']); if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?><?php echo htmlspecialchars($game['team2']); ?></span>
|
||||
</strong></p>
|
||||
|
||||
<?php if ($error): ?>
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ $teamLogo = function ($name) {
|
|||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="team-cell"><?php $l1 = $teamLogo($game['team1']); if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo"><?php endif; ?><?php echo htmlspecialchars($game['team1']); ?></span>
|
||||
<span class="team-cell"><?php $l1 = $teamLogo($game['team1']); if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?><?php echo htmlspecialchars($game['team1']); ?></span>
|
||||
:
|
||||
<span class="team-cell"><?php $l2 = $teamLogo($game['team2']); if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo"><?php endif; ?><?php echo htmlspecialchars($game['team2']); ?></span>
|
||||
<span class="team-cell"><?php $l2 = $teamLogo($game['team2']); if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?><?php echo htmlspecialchars($game['team2']); ?></span>
|
||||
</td>
|
||||
<td><?php echo date('d.m.Y H:i', strtotime($game['kickoff'])); ?></td>
|
||||
<td><?php echo (int)$game['score1'] > -1 ? (int)$game['score1'] . ' : ' . (int)$game['score2'] : ''; ?></td>
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ $teamLogo = function ($name) {
|
|||
$gameId = (int)$game['id'];
|
||||
?>
|
||||
<tr>
|
||||
<td><span class="team-cell"><?php $l1 = $teamLogo($game['team1']); if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo"><?php endif; ?><?php echo htmlspecialchars($game['team1']); ?></span></td>
|
||||
<td><span class="team-cell"><?php $l1 = $teamLogo($game['team1']); if ($l1): ?><img src="<?php echo htmlspecialchars($l1); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?><?php echo htmlspecialchars($game['team1']); ?></span></td>
|
||||
<td>:</td>
|
||||
<td><span class="team-cell"><?php $l2 = $teamLogo($game['team2']); if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo"><?php endif; ?><?php echo htmlspecialchars($game['team2']); ?></span></td>
|
||||
<td><span class="team-cell"><?php $l2 = $teamLogo($game['team2']); if ($l2): ?><img src="<?php echo htmlspecialchars($l2); ?>" alt="" class="team-logo" loading="lazy"><?php endif; ?><?php echo htmlspecialchars($game['team2']); ?></span></td>
|
||||
<td class="score">
|
||||
<input type="number" min="0" max="99" name="scores[<?php echo $gameId; ?>][score1]" required
|
||||
value="<?php echo htmlspecialchars((string)($formScores[$gameId]['score1'] ?? '')); ?>">
|
||||
|
|
|
|||
|
|
@ -156,6 +156,20 @@ def build_htaccess(creds, app_url):
|
|||
"RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]",
|
||||
"</IfModule>",
|
||||
"",
|
||||
"<IfModule mod_headers.c>",
|
||||
" # 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).",
|
||||
" <FilesMatch \"\\.(png|jpe?g|gif|svg|webp|ico|css|woff2?)$\">",
|
||||
" Header set Cache-Control \"public, max-age=604800\"",
|
||||
" </FilesMatch>",
|
||||
" # Der Service Worker steuert die App-Updates und darf nicht lange",
|
||||
" # im Cache haengen, sonst bleiben Aenderungen tagelang unsichtbar.",
|
||||
" <Files \"sw.js\">",
|
||||
" Header set Cache-Control \"no-cache\"",
|
||||
" </Files>",
|
||||
"</IfModule>",
|
||||
"",
|
||||
]
|
||||
for name in HTACCESS_ORDER:
|
||||
if values.get(name):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue