Cache avatars and emotes, and send Cache-Control headers !9

merged merged by cmc on 2026-09-11 15:13 UTC · krz/skunky-art:feat/avatar-cache-headers into main

Discussion

cmc

Stacked on !8; retarget to main once that merges.

Emojitar stores fetched avatars and emotes in the media cache (disk, plus memory when memcache is on) keyed by type and lowercased name, so each is fetched once per cache lifetime. A miss is not stored. With cache.enabled off nothing changes but the headers.

Every response carries Cache-Control: a year and immutable on /media/file (signed wixmp URLs never change content), a day on avatars, emotes, /stylesheet and /favicon.ico, five minutes on pages and API JSON. Error responses drop the header. The catch-all handler is now Handler() so routes can be tested; Router just serves it.

Four new tests: header per route including error routes, avatar served from cache after one fetch, a miss not cached, cache off fetches every time.

Closes #9

Closes #16: Emojitar now returns after the 404 instead of writing a body over it.

retargeted from feat/api-cache to main: !8 merged

2026-09-11 15:13 UTC