Repository navigation
Conversation
… with 304 serveStaticFile sent `Cache-Control: no-cache` for /uploads and the admin shell files but no ETag or Last-Modified, so the browser had nothing to revalidate with and re-downloaded every file in full. The editor preview iframe reloads every image and font on each rebuild: about 117 requests and 3.7 MB per preview load on one production site. Responses now carry a weak ETag (size + mtime) and Last-Modified, and If-None-Match / If-Modified-Since get a bodiless 304 (If-None-Match wins, per RFC 9110). A media replace that keeps the path changes the mtime, so the validator changes with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ngocht
marked this pull request as ready for review
October 15, 2026 09:20
This branch has not been deployed
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.
Summary
serveStaticFile(server/static.ts) sendsCache-Control: no-cachefor/uploads/*and for admin shell files outside/assets/.no-cachetells the browser to revalidate before reusing a cached copy. The responses carried noETagorLast-Modified, though, so the browser had nothing to revalidate with and downloaded every file in full each time.This hits the editor preview hardest: the preview iframe reloads every image and font on each rebuild. On one production site (75 pages, image-heavy), one preview load was about 117 requests and 3.7 MB, all of it unchanged media, and that site's
/uploadstraffic reached 64 MB before noon.Changes:
serveStaticFilenow carry a weakETag(file size + mtime) andLast-Modified.If-None-MatchandIf-Modified-SinceonGET/HEADget a bodiless304with the sameCache-Control, the validators and, for compressible files,Vary: accept-encoding.If-None-Matchtakes precedence, as RFC 9110 §13.1 requires, and handles lists and*.public_path(replaceMediaAssetBinaryallows that) rewrites the file, which changes the mtime and with it the validator. Caching therefore stays correct withoutimmutableon uploads.stat, not a full read into memory./uploads/*responses still go throughhardenUploadResponse, so a 304 keepsnosniff, the CSP and the plugin CORS headers.Running on that production site as a patched build: the same image now answers a conditional request with
304, 0 bytes, where it used to send 194 KB.Verification
bun run build— rantsc -p tsconfig.app.jsonandtsc -p tsconfig.node.json(clean)bun test— ranbun test src/__tests__/server: 1116 pass. Two new tests instaticAdmin.test.ts, both of which fail without the change:If-None-Match,If-Modified-Since(older and current),If-None-Matchprecedence, the security headers on the 304, and a rewrite of the same path returning 200 with a new ETag./assets/file.The compressed path isn't exercised in tests: the test preload installs happy-dom's
Request, which dropsAccept-Encodingas a forbidden header.bun run lint— eslint on the changed files (clean)Docker/deployment check, if relevant
Checklist
🤖 Generated with Claude Code