[Perf] Thumbnail-Endpoint + pHash/EXIF-Cache #23

Closed
opened 2026-05-27 12:21:05 +02:00 by ferdi2go · 1 comment
Owner

Probleme

a) /preview liefert Original-JPEG als Thumbnailindex.html:1293, server.py:227-238
Review-Liste laedt bei 200 Fotos potenziell 200x3 MB = 600 MB.

b) Keine Cache-Header auf /preview, /exif. Browser re-fetcht bei jedem Reload.

c) Kein pHash/EXIF-Cache zwischen Runs. Re-Analyse rechnet alles neu.

Fix

  • a) Neuer Endpoint /thumb?path=...&w=200 mit Disk-Cache.
  • b) ETag aus mtime + Cache-Control: private, max-age=3600.
  • c) analyzer_cache.json mit {md5+mtime: {phash, exif, brightness, ...}}.
## Probleme **a) `/preview` liefert Original-JPEG als Thumbnail** — `index.html:1293`, `server.py:227-238` Review-Liste laedt bei 200 Fotos potenziell 200x3 MB = 600 MB. **b) Keine Cache-Header** auf `/preview`, `/exif`. Browser re-fetcht bei jedem Reload. **c) Kein pHash/EXIF-Cache** zwischen Runs. Re-Analyse rechnet alles neu. ## Fix - a) Neuer Endpoint `/thumb?path=...&w=200` mit Disk-Cache. - b) `ETag` aus mtime + `Cache-Control: private, max-age=3600`. - c) `analyzer_cache.json` mit `{md5+mtime: {phash, exif, brightness, ...}}`.
ferdi2go added the priority: mediummaintenance labels 2026-05-27 12:21:05 +02:00
Author
Owner

Fix (a) und (b) umgesetzt:

(a) /thumb-Endpoint

  • Neuer Endpoint GET /thumb?path=...&w=200 (min 32, max 800)
  • Disk-Cache unter <tempdir>/of-thumbs/<md5(path|mtime|w)>.jpg
  • JPEG quality=80, optimize=true, LANCZOS-Resize
  • Frontend: makeThumb nutzt jetzt /thumb?w=240 (Lightbox-Klick laedt weiterhin /preview mit voller Aufloesung)

(b) Cache-Header

  • Helper _file_etag, _cache_response, _not_modified_if
  • /preview, /thumb, /exif setzen ETag (mtime-size + ggf. -wN) und Cache-Control: private, max-age=3600
  • 304 Not Modified wird zurueckgegeben wenn If-None-Match passt

Manueller Test mit 2000x1500 JPEG (47 KB):

  • /thumb?w=240 -> 556 B (99% Ersparnis)
    1. Request mit ETag -> HTTP 304
  • /preview mit ETag -> HTTP 304

(c) pHash/EXIF-Disk-Cache zwischen Runs als separates Issue #29 ausgegliedert.

Fix (a) und (b) umgesetzt: **(a) `/thumb`-Endpoint** - Neuer Endpoint `GET /thumb?path=...&w=200` (min 32, max 800) - Disk-Cache unter `<tempdir>/of-thumbs/<md5(path|mtime|w)>.jpg` - JPEG quality=80, optimize=true, LANCZOS-Resize - Frontend: `makeThumb` nutzt jetzt `/thumb?w=240` (Lightbox-Klick laedt weiterhin `/preview` mit voller Aufloesung) **(b) Cache-Header** - Helper `_file_etag`, `_cache_response`, `_not_modified_if` - `/preview`, `/thumb`, `/exif` setzen `ETag` (`mtime-size` + ggf. `-wN`) und `Cache-Control: private, max-age=3600` - 304 Not Modified wird zurueckgegeben wenn `If-None-Match` passt Manueller Test mit 2000x1500 JPEG (47 KB): - `/thumb?w=240` -> 556 B (99% Ersparnis) - 2. Request mit ETag -> HTTP 304 - `/preview` mit ETag -> HTTP 304 **(c) pHash/EXIF-Disk-Cache zwischen Runs** als separates Issue #29 ausgegliedert.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ferdi2go/OnlyFrames#23