fix(images): browser-cacheable cover art and SPA assets#743
Draft
kevinheneveld wants to merge 1 commit into
Draft
fix(images): browser-cacheable cover art and SPA assets#743kevinheneveld wants to merge 1 commit into
kevinheneveld wants to merge 1 commit into
Conversation
The /images/{id} endpoint (the grid's hot path — the frontend rewrites
/config/cache/images/* URLs to it) served covers with Cache-Control:
private, max-age=3600. On a ~3.2k-book library that meant a full
~100MB cover refetch on any browse more than an hour after the last.
Raise to 7 days; PhysicalFileResult already answers If-Modified-Since
with 304 (verified live), so post-expiry revalidation costs zero bytes.
Also:
- /config/cache/images static middleware (direct-path consumers) gains
public, max-age=604800 — it already emits ETags for revalidation.
- SPA static assets had NO Cache-Control at all: content-hashed
/assets/* now cache forever (max-age=31536000, immutable) and
index.html — including the SPA-route fallback — is no-cache, so a
deploy can no longer strand browsers on a stale shell referencing
purged asset hashes.
Image URLs carry no per-session tokens (verified: getImageUrl builds
plain /images/{id} paths; auth rides headers/cookies), so browser
caching is safe across sessions.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Cover images served via
/api/v1/images/{id}carryCache-Control: private, max-age=3600— on a large library the browser refetches every cover after an hour, hammering the server on each browse (measured: ~3.2k covers, ~100MB per full grid render). This PR:private, max-age=604800(7 days; ETag/Last-Modified already answer revalidation with 0-byte 304s)public, max-age=604800to the/config/cache/imagesstatic middleware/assets/*nowpublic, max-age=31536000, immutable;index.html(both static and SPA-fallback routes) nowno-cache, which also fixes a stale-app-shell-after-deploy hazardTests
2 header-pinning tests; full suite passing.
🤖 Generated with Claude Code