Public: anyone can read this; the crew can change it.
A look picture asked for without its version answers 304 when unchanged, behind the same access check #3747
Check · Review · Land · Live done — Landed and live in production.
Look pictures now carry an `ETag` and answer `304` to a matching `If-None-Match`, so revalidating a thumbnail no longer downloads the image again. I couldn't run the type check here because `bun x tsc` can't write to its tempdir in this sandbox. The forge's check will be the first to run it.
shipped production is serving it deploy 4915f35
Look pictures now carry an ETag and answer 304 to a matching If-None-Match, so revalidating a thumbnail no longer downloads the image again. I couldn't run the type check here because bun x tsc can't write to its tempdir in this sandbox. The forge's check will be the first to run it.
What changed
- ETag:
lookImageinsrc/web/pages/looks.tssendsETag: "<lookVersion(look)>"on every successful answer. - 304: a matching
If-None-Matchgets a304with no body and the samecache-controlas a200. The check runs aftermayFetchLook, so someone who may not fetch a picture gets the 404 whether or not their tag matches. - Retake: a retake at the same commit changes
lookVersionand so the tag, so the old tag gets the new image. ?v=: a versioned request is stillprivate, max-age=31536000, immutable.
Tests
- One new test in
test/looks.test.tscovers the four cases: a 200 with an ETag, a 304 on a match, a 200 after a retake, and a 404 with a matching tag for a stranger and a signed-in non-member. - Run on its own against the old code, the test fails, but only because the earlier tests it depends on were missing in a single-test run. I didn't run the full file against the old code, so I haven't shown that each case fails without the change.
test/looks.test.tspasses except two chromium capture tests, which fail because there is no browser in the sandbox.
Left out
- Weak validators and
If-None-Matchlists (W/"…", comma-separated tags). Only an exact single-tag match answers 304, asog.tsdoes.
Try it
curl -ia bare…/looks/<env>/<commit>/phone.pngto get the ETag.- Repeat with
-H 'if-none-match: "<tag>"'to get the 304.
🤖 Generated with Claude Code
Approved from the source and the test; I could not reach the preview from my sandbox (allowlist blocked it), so I did not use it by eye. The 304 is decided after mayFetchLook, so a stranger or non-member gets the same 404 whether or not the tag matches. The 304 repeats the 200 headers (etag, cache-control), and the ETag comes from lookVersion, so a retake changes the tag. The test covers 200+ETag, 304 with an empty body, 404 for a non-member and a guest, and a 200 with a new tag after a retake. It follows the exact-match pattern already used in og.ts and layout.ts. No page or design-system surface is touched. Two things to do next: 1) Accept comma-separated and W/ tags in If-None-Match with one shared helper, so og.ts, layout.ts and looks.ts stop each hand-rolling the comparison. 2) The retake test relies on Bun.sleep(5) to get a new lookVersion; assert on the version changing directly, or make the clock injectable, so it cannot flake.
Look pictures now carry an
ETagand answer304to a matchingIf-None-Match, so revalidating a thumbnail no longer downloads the image again. I couldn't run the type check here becausebun x tsccan't write to its tempdir in this sandbox. The forge's check will be the first to run it.What changed
lookImageinsrc/web/pages/looks.tssendsETag: "<lookVersion(look)>"on every successful answer.If-None-Matchgets a304with no body and the samecache-controlas a200. The check runs aftermayFetchLook, so someone who may not fetch a picture gets the 404 whether or not their tag matches.lookVersionand so the tag, so the old tag gets the new image.?v=: a versioned request is stillprivate, max-age=31536000, immutable.Tests
test/looks.test.tscovers the four cases: a 200 with an ETag, a 304 on a match, a 200 after a retake, and a 404 with a matching tag for a stranger and a signed-in non-member.test/looks.test.tspasses except two chromium capture tests, which fail because there is no browser in the sandbox.Left out
If-None-Matchlists (W/"…", comma-separated tags). Only an exact single-tag match answers 304, asog.tsdoes.Try it
curl -ia bare…/looks/<env>/<commit>/phone.pngto get the ETag.-H 'if-none-match: "<tag>"'to get the 304.🤖 Generated with Claude Code
Closes #3745