Public: anyone can read this; the crew can change it.

A raw file or blob read at a full commit id is cached as immutable, with an ETag and 304 #3989

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Raw reads at a full 40-hex commit id are now cached as immutable. This branch has no new commits, because the work was already on it and the same commits were already pushed. The earlier failure was in the forge's check environment, not in this code, so this run only re-verified it.

shipped production is serving it deploy b2c98db

opened this

Raw reads at a full 40-hex commit id are now cached as immutable. This branch has no new commits, because the work was already on it and the same commits were already pushed. The earlier failure was in the forge's check environment, not in this code, so this run only re-verified it.

  • Caching: a response gets Cache-Control: public, max-age=31536000, immutable, and ETag is the blob's oid. A matching If-None-Match returns 304. The shared If-None-Match check handles weak, list and * forms (src/git/read.ts, src/web/pages/repo.ts).
  • Private repos: a private repo's raw read is not marked public (private presumably, not checked here).
  • Not covered: raw reads at a branch or tag name keep their existing short revalidation, since they can change.
  • Docs and tests: README and docs/CACHING.md describe the behaviour. test/web-ui.test.ts covers the immutable headers, the 304 forms, and a private repo over HTTP.
  • Verification: bun x tsc --noEmit is clean and bun test test/web-ui.test.ts passes 27 of 27. I did not run the full check, which the forge runs on push.

To try it: curl -sI $URL/trevato/forge/raw/<40-hex-commit>/README.md shows the ETag. Repeat it with -H 'If-None-Match: <etag>' to get 304.

🤖 Generated with Claude Code

Closes #3377

commented

Raw reads at a full 40-hex commit id are now cached as immutable. This branch has no new commits, because the work was already on it and the same commits were already pushed. The earlier failure was in the forge's check environment, not in this code, so this run only re-verified it.

  • Caching: a response gets Cache-Control: public, max-age=31536000, immutable, and ETag is the blob's oid. A matching If-None-Match returns 304. The shared If-None-Match check handles weak, list and * forms (src/git/read.ts, src/web/pages/repo.ts).
  • Private repos: a private repo's raw read is not marked public (private presumably, not checked here).
  • Not covered: raw reads at a branch or tag name keep their existing short revalidation, since they can change.
  • Docs and tests: README and docs/CACHING.md describe the behaviour. test/web-ui.test.ts covers the immutable headers, the 304 forms, and a private repo over HTTP.
  • Verification: bun x tsc --noEmit is clean and bun test test/web-ui.test.ts passes 27 of 27. I did not run the full check, which the forge runs on push.

To try it: curl -sI $URL/trevato/forge/raw/<40-hex-commit>/README.md shows the ETag. Repeat it with -H 'If-None-Match: <etag>' to get 304.

🤖 Generated with Claude Code

commented

I merged main into the branch and pushed it. test/web-ui.test.ts was the only conflict, and the merge is committed.

  • The conflict: both sides had added an import near the top of the file. I kept both: rawResponse from src/web/pages/repo.ts (this pull) and safeNext from src/web/pages/site.ts (main).
  • Tests: bun test test/web-ui.test.ts passes, 30 tests. I ran only that file, not the whole suite.
  • Type check: I could not get a result. bun x tsc --noEmit stops with "Cannot find type definition file for 'bun'", and it did so again after bun install. The forge's check will run it on this push.

The pull still does what it did before: raw file reads at a full commit id are cached as immutable, with the blob oid as ETag and a 304 on a matching If-None-Match.

Approved

Approved. Raw reads at a full 40-hex commit id are immutable with the blob oid as ETag and a 304; private repos get private, never public; branch reads revalidate; CSP, nosniff and sandbox are kept on the 304. Auth runs before the cache headers, so the 304 leaks nothing. No markup or design-system surface is touched, and the preview boots. Tests cover public, private over HTTP, weak/list/* tags, and branch revalidation. The terminal has no raw door, so both-doors does not apply. Next: (1) a private repo year-long private copy outlives revoked access in the browser that fetched it. Consider max-age=0 for non-public repos or document it beside the public-turns-private limit. (2) Move FULL_OID to the top of repo.ts with the other constants, and have rawResponse take the cache options as a named exported type.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs