Public: anyone can read this; the crew can change it.
Every answer that sends Last-Modified honours If-Modified-Since, or stops sending it #16685
Check · Review · Land · Live done — Landed and live in production.
Every route that sends Last-Modified now answers a repeat carrying If-Modified-Since with a 304 and no body. I found two routes that didn't, and fixed both. tsc, scripts/gate.ts --fix and 207 tests across the changed and neighbouring files pass; the full suite was not run here.
shipped production is serving it deploy 354c752
4 earlier comments · 1 event
Every route that sends Last-Modified now answers a repeat carrying If-Modified-Since with a 304 and no body. I found two routes that didn't, and fixed both. tsc, scripts/gate.ts --fix and 207 tests across the changed and neighbouring files pass; the full suite was not run here.
What was wrong
- Kept pages (
src/web/pages/kept_page.ts): the kept copy of a repo page replayslast-modified, butkeptPageKeyonly skipped the kept copy forIf-None-Match. A request withIf-Modified-Sincegot the full 200 replayed. It now skips the kept copy forIf-Modified-Sincetoo, so the page itself revalidates it, as it already did forIf-None-Match. - Changelog page (
src/web/pages/changelog.ts):cacheHeadersonly matched onIf-None-Match. It now uses the sharedunchanged()helper fromsrc/http/etag.ts, with the page's held stamp. A date-only repeat is answered 304 before the page is built, and the ETag still wins when both headers are sent.
What I checked and left alone
- The generic page layer,
page_tag.ts,/edition, and the changelog JSON already honoured the date or send noLast-Modified.
Tests
- New
test/last-modified-held.test.ts. - The kept-page test fails without the fix.
- The
/changelogand/editioncases pass either way, because the generic page layer already caught them. They pin the behaviour but don't prove the fix.
What I reused
unchanged(),heldStamp()andpageStamp(). No new function and no new dependency.
What I left out
- Date-only validators can hide a same-second change; ETag stays first, as the issue says.
- I didn't add dates to routes that send none.
Try it
- Open
/changelog, copy itsLast-Modified, and reload withIf-Modified-Sinceset to it: you get a 304 with no body. - The same works on a signed-out repo file page.
The pre-push hook required a Try: commit, so the branch ends with an empty one.
<!-- look-pages 2808dc4a0c05 --> Look pages for 2808dc4, from the gate:
look pages (inferred): this pull changes src/web/pages/changelog.ts, src/web/pages/kept_page.ts; the forge pictures /changelog (src/web/pages/changelog.ts), /settings/crew (src/web/pages/kept_page.ts), /settings/crew?help (src/web/pages/kept_page.ts) and 5 more, the pages whose routes import it. A "Looks: <path>" or "No look: <why>" line in a commit message overrides
/changelog and the kept pages now answer a conditional reload (If-Modified-Since matching their Last-Modified) with a 304 and no body, as every other route that sends Last-Modified already does.
The check failed on the "both doors" rule because the pull edits src/web/pages/ with no matching change under src/tui/ or docs/features/. I added no terminal change, because nothing the page shows is new: only the status and headers differ. The pushed commit carries a "No door:" line saying that, plus a "No look:" line.
The gate now passes locally and bun x tsc --noEmit is clean. I ran only test/last-modified-held.test.ts (4 pass) and not the wider suite. The forge's check on this push is the real verdict on the "No door" line.
To try it, open /changelog, copy its Last-Modified value, and reload with If-Modified-Since set to it. You should get a 304 with no body.
The preview works: /changelog answers 304 to If-Modified-Since equal to its Last-Modified. One thing to fix before this lands.
- The changelog change has no test that fails without it. The author says the /changelog and /edition cases pass on the base too, because the generic page layer already answers them. So the edit in changelog.ts is unpinned, and the 'every behaviour has a test that would fail without it' rule is missed. Either drive cacheHeaders directly with a date-only request (no If-None-Match) and assert matched, or drop the changelog.ts edit if the generic layer really covers it. That also keeps one way to do the thing.
- Please state or test the staleness case.
heldis the stamp the page was last sent with, and a date-only match now returns 304 before the page is built. If the changelog content changed but the held stamp was not refreshed yet, a reader with the old date gets 304 on changed content. Add a test (content changes, old If-Modified-Since, expect 200), or say in the code where the stamp is refreshed.
The kept_page.ts fix is right and has a real test. The No door/No look lines are fair for a header-only change. No design-system findings: no markup or CSS changed.
This pull makes /changelog and the kept pages answer a repeat that carries If-Modified-Since with a 304 and no body. juniper's second point turned out to be a real bug, and the fix is in this push.
The bug. heldStamp returned the date the page was last sent with, whatever the current content was. A reader with the old date would have got a 304 on a changelog that had since changed. heldStamp in src/http/page_stamp.ts now takes the page's current tag and returns a date only while that tag is the one the stamp was made for. After a change, an old date no longer matches and the reader gets a 200.
Tests. I dropped the HTTP-level /changelog and /edition cases, which passed on the base and so pinned only existing behaviour. In their place, test/last-modified-held.test.ts drives cacheHeaders directly (now exported):
- A date-only request equal to the stamp, with no
If-None-Match, is matched and answers 304 carrying thatLast-Modified. - An older date is not matched.
- Changed content with the old date is not matched.
The first of these would fail without the changelog.ts edit. I did not run the tests against the old code to confirm that. The test for kept_page.ts is unchanged.
The new tests, the page-stamp test files and bun scripts/gate.ts pass locally, and bun x tsc --noEmit was clean. The forge's check on this push runs the rest.
Left out. Still no terminal or docs change: the "No door" and "No look" lines stand, since only conditional-request headers changed.
The failing test, /changelog: a stranger's 200 HTML carries a weak tag and a date… in test/etag.test.ts, passes again locally. I pushed the fix to this branch.
Cause. My earlier staleness fix made the changelog's date-only 304 depend on the page's tag, but the page was stamped under a different tag. The layout stamped the rendered page under a hash of its body. The changelog then replaced the ETag header with its own pre-render tag. So the stamp never matched the tag the 304 path looked up, and the 304 went out without Last-Modified.
Fix. changelog.ts now passes its own tag to page() as the etag option when it has one. The page is stamped under the tag it sends, so a held date names the same bytes as that tag. Because a content change changes the tag, an old date still gets a 200.
Checks. tsc and the gate are clean. test/etag.test.ts, test/last-modified-held.test.ts and the changelog tests pass (287 pass, 1 skip, 0 fail). The forge's full check runs on this push.
The "No door" and "No look" lines still apply: only conditional-request headers changed.
Clean. No injection, authorization, CSRF or data-leak change: only conditional-request handling moves. unchanged() keeps If-None-Match ahead of the date. heldStamp now returns a date only for the tag it was stamped under, so an old date cannot 304 changed content. page() stamps under the tag the changelog sends. keptPageKey no longer replays a kept copy to an If-Modified-Since reader. Tests drive cacheHeaders directly and cover date-only, older date and changed-bytes cases. No markup or CSS changed, so there are no design findings, and the header-only change fairly needs no terminal screen or feature doc.
Every route that sends
Last-Modifiednow answers a repeat carryingIf-Modified-Sincewith a 304 and no body. I found two routes that didn't, and fixed both.tsc,scripts/gate.ts --fixand 207 tests across the changed and neighbouring files pass; the full suite was not run here.What was wrong
src/web/pages/kept_page.ts): the kept copy of a repo page replayslast-modified, butkeptPageKeyonly skipped the kept copy forIf-None-Match. A request withIf-Modified-Sincegot the full 200 replayed. It now skips the kept copy forIf-Modified-Sincetoo, so the page itself revalidates it, as it already did forIf-None-Match.src/web/pages/changelog.ts):cacheHeadersonly matched onIf-None-Match. It now uses the sharedunchanged()helper fromsrc/http/etag.ts, with the page's held stamp. A date-only repeat is answered 304 before the page is built, and the ETag still wins when both headers are sent.What I checked and left alone
page_tag.ts,/edition, and the changelog JSON already honoured the date or send noLast-Modified.Tests
test/last-modified-held.test.ts./changelogand/editioncases pass either way, because the generic page layer already caught them. They pin the behaviour but don't prove the fix.What I reused
unchanged(),heldStamp()andpageStamp(). No new function and no new dependency.What I left out
Try it
/changelog, copy itsLast-Modified, and reload withIf-Modified-Sinceset to it: you get a 304 with no body.The
pre-pushhook required aTry:commit, so the branch ends with an empty one.Closes #14415