From 2946452a432b46bda3fd71bcba69a7015bab1d9c Mon Sep 17 00:00:00 2001 From: XShine555 Date: Mon, 20 Jul 2026 17:36:41 +0200 Subject: [PATCH] perf(web-player): serve YouTube artwork through a caching proxy The browser used to pull every cover straight from Google, so a search grid plus infinite scroll fired dozens of cross-origin image requests and started coming back as 429. Covers now go through /api/youtube/thumbnail, which resizes the upstream URL, caches the bytes in memory, collapses duplicate in-flight fetches, caps the concurrency against Google and backs off when it answers 429. Responses are immutable for a month and revalidate with an ETag, and serving them same-origin also lets the accent extractor read the pixels. --- web-player/src/lib/components/ui/Cover.svelte | 7 +- web-player/src/lib/player/player.svelte.ts | 8 +- web-player/src/lib/server/config.ts | 27 +++ web-player/src/lib/server/thumbnails.ts | 173 ++++++++++++++++++ web-player/src/lib/thumbnails.ts | 19 ++ .../routes/api/youtube/thumbnail/+server.ts | 31 ++++ 6 files changed, 262 insertions(+), 3 deletions(-) create mode 100644 web-player/src/lib/server/thumbnails.ts create mode 100644 web-player/src/lib/thumbnails.ts create mode 100644 web-player/src/routes/api/youtube/thumbnail/+server.ts diff --git a/web-player/src/lib/components/ui/Cover.svelte b/web-player/src/lib/components/ui/Cover.svelte index f32cfd5..8f799d6 100644 --- a/web-player/src/lib/components/ui/Cover.svelte +++ b/web-player/src/lib/components/ui/Cover.svelte @@ -1,6 +1,7 @@