Public: anyone can read this; the crew can change it.
A signed-in source archive is never marked shared-cacheable #15014
Check · Review · Land · Live done — Landed and live in production.
If you are signed in, a source archive at a full commit id is no longer marked shared-cacheable. Anonymous archives of public repositories still are. Closes #14948 (one finding from #14765).
shipped production is serving it deploy 9504585
If you are signed in, a source archive at a full commit id is no longer marked shared-cacheable. Anonymous archives of public repositories still are. Closes #14948 (one finding from #14765).
src/http/archive.ts: the archive decides caching throughmayShare, the same check the raw-file route (rawBlob) uses. An anonymous request for a public repository at a full id getsPINNED_PUBLIC(a one-year browser cache, one day in a shared cache) andVary: EDGE_VARY. A signed-in request at a full id getsprivate, max-age=31536000, immutable, so the browser still keeps the bytes it can't change. A branch or tag staysno-cache.src/http/respond.ts:privateWhenSignedInused to skip any response whose Cache-Control saidimmutable. That let a credentialed archive keeppublic. It now skips only a fixed list of static-asset paths: hashed files under/assets/, the hashed toolbar scripts under/__forge/,/icons/*.png,/favicon.icoand the apple-touch icons. Every other credentialed answer losespublicands-maxage, whatever else its header says.test/archive-cache.test.ts(new):- Signed out, the archive is
PINNED_PUBLICwith the Vary header. - Signed in by session cookie or by bearer token, it is private and immutable, with no
publicand nos-maxage. - A branch archive is
no-cache. - Signed in, a hashed asset keeps its public year.
- Unit cases for the path list.
Four of its six tests fail on today's main, both signed-in cases among them.
- Signed out, the archive is
test/cache-private.test.ts: I changed one assertion because it encoded the bug: it expected animmutableresponse at/to stay public when signed in. It now expects that for an/assets/path, and expects/to come back private.
To look at: the path list in STATIC_ASSET_PATH. A hashed static asset served from a path it doesn't cover would go out private to signed-in browsers. That only costs shared-cache hits, never exposure. I left out the /__forge/ paths other than the two hashed toolbar scripts, because most of them depend on who is asking.
To try it: on the preview, run curl -I <preview>/<owner>/<repo>/archive/<full-oid>.tar.gz for a public repository, once without and once with your forge_session cookie. Signed out you should see public, …, s-maxage=86400, immutable; signed in, private, max-age=31536000, immutable.
Checks: bun scripts/gate.ts --fix and bun x tsc --noEmit are clean. scripts/fast.ts named 2,480 test files because respond.ts reaches almost everything, so I picked the 28 files that mention privateWhenSignedIn, immutable, PINNED_PUBLIC or archive URLs: 485 pass, 0 fail. The full suite runs in the forge's check.
The repository's pre-push hook wanted a commit saying how to try the change, so there is an empty Try: commit.
🤖 Generated with Claude Code
Clean, small security fix. The archive goes through mayShare with PINNED_PUBLIC and EDGE_VARY like rawBlob. A credentialed answer now loses public/s-maxage unless the path is a static asset. The tests cover anonymous, cookie, bearer, branch, assets and the path list. The pull is green.
If you are signed in, a source archive at a full commit id is no longer marked shared-cacheable. Anonymous archives of public repositories still are. Closes #14948 (one finding from #14765).
src/http/archive.ts: the archive decides caching throughmayShare, the same check the raw-file route (rawBlob) uses. An anonymous request for a public repository at a full id getsPINNED_PUBLIC(a one-year browser cache, one day in a shared cache) andVary: EDGE_VARY. A signed-in request at a full id getsprivate, max-age=31536000, immutable, so the browser still keeps the bytes it can't change. A branch or tag staysno-cache.src/http/respond.ts:privateWhenSignedInused to skip any response whose Cache-Control saidimmutable. That let a credentialed archive keeppublic. It now skips only a fixed list of static-asset paths: hashed files under/assets/, the hashed toolbar scripts under/__forge/,/icons/*.png,/favicon.icoand the apple-touch icons. Every other credentialed answer losespublicands-maxage, whatever else its header says.test/archive-cache.test.ts(new):PINNED_PUBLICwith the Vary header.publicand nos-maxage.no-cache.Four of its six tests fail on today's main, both signed-in cases among them.
test/cache-private.test.ts: I changed one assertion because it encoded the bug: it expected animmutableresponse at/to stay public when signed in. It now expects that for an/assets/path, and expects/to come back private.To look at: the path list in
STATIC_ASSET_PATH. A hashed static asset served from a path it doesn't cover would go outprivateto signed-in browsers. That only costs shared-cache hits, never exposure. I left out the/__forge/paths other than the two hashed toolbar scripts, because most of them depend on who is asking.To try it: on the preview, run
curl -I <preview>/<owner>/<repo>/archive/<full-oid>.tar.gzfor a public repository, once without and once with yourforge_sessioncookie. Signed out you should seepublic, …, s-maxage=86400, immutable; signed in,private, max-age=31536000, immutable.Checks:
bun scripts/gate.ts --fixandbun x tsc --noEmitare clean.scripts/fast.tsnamed 2,480 test files becauserespond.tsreaches almost everything, so I picked the 28 files that mentionprivateWhenSignedIn,immutable,PINNED_PUBLICor archive URLs: 485 pass, 0 fail. The full suite runs in the forge's check.The repository's pre-push hook wanted a commit saying how to try the change, so there is an empty
Try:commit.🤖 Generated with Claude Code
Closes #14948