Make media URLs stable and cacheable, add real image thumbnails
Signed media URLs embedded the current second (TimestampSigner), so every API response re-minted every raw/thumbnail/staged URL and the browser re-downloaded each file on every poll or navigation. Responses also carried no cache headers at all. - sign with a plain Signer plus a bucket-quantized exp (7d TTL, 24h bucket), so a URL is byte-identical across responses and rotates once a day; legacy TimestampSigner URLs stay accepted for one release - add a v=<md5> version parameter to library media URLs so replacing a file under the same J-ID (the optimize flow) busts caches exactly when needed - serve_file now sends ETag/Last-Modified and a private Cache-Control and answers conditional requests with 304; library media gets max-age 6d + immutable, staged/similarity files 1h - build cached 480px JPEG thumbnails for images (Pillow, keyed by MD5 under MEDIA_ROOT/thumbs) instead of serving full-size originals through the thumbnail endpoint; the library grid uses thumbnail_url for images too
This commit is contained in:
@@ -18,9 +18,9 @@ const ratingLabels: Record<string, string> = {
|
||||
};
|
||||
|
||||
export function MediaCard({ item }: { item: MediaItem }) {
|
||||
const preview = apiUrl(
|
||||
item.kind === "video" ? item.thumbnail_url : item.raw_url,
|
||||
);
|
||||
// The thumbnail endpoint now builds real 480px previews for images too, so
|
||||
// the grid no longer pulls full-size originals.
|
||||
const preview = apiUrl(item.thumbnail_url);
|
||||
const rating = item.display_rating;
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user