fix: cache immutable blobs served from /files

Page and cover blobs are content-addressed by unguessable, immutable keys,
but /files sent no Cache-Control, so the browser refetched on every reader
open — defeating the whole-chapter and next-chapter preloading (and re-
proxying every byte through the node server in prod). Send
`Cache-Control: public, max-age=31536000, immutable`.

Bump to 0.124.3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-07-07 20:30:03 +02:00
parent 379224bee4
commit b0500e8e48
5 changed files with 20 additions and 3 deletions

View File

@@ -49,6 +49,16 @@ async fn serve(State(state): State<AppState>, Path(key): Path<String>) -> AppRes
HeaderName::from_static("x-content-type-options"),
"nosniff".to_string(),
),
// Blobs are content-addressed by unguessable, immutable keys (a
// re-upload mints new UUIDs), so a fetched page/cover never changes.
// Cache it for a year and mark it `immutable` so browsers skip
// revalidation entirely — this is what lets the reader's page and
// next-chapter preloading hit cache instead of re-downloading (and
// re-proxying every byte through the SvelteKit node server in prod).
(
header::CACHE_CONTROL,
"public, max-age=31536000, immutable".to_string(),
),
];
Ok((headers, Body::from_stream(file.stream)).into_response())
}