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

Signed-out /pricing and /templates are kept by the edge for a minute, like / and /explore #14667

Merged opened this

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

Merged

A signed-out GET of /pricing or /templates now answers public, max-age=0, s-maxage=60, stale-while-revalidate=300, with Vary carrying EDGEVARY. I changed sharedPath in src/http/edgecache.ts and extended test/web-budget.test.ts.

Notes

shipped production is serving it deploy 4ec2c16

opened this

A signed-out GET of /pricing or /templates now answers public, max-age=0, s-maxage=60, stale-while-revalidate=300, with Vary carrying EDGE_VARY. I changed sharedPath in src/http/edge_cache.ts and extended test/web-budget.test.ts. That test file and tsc pass; I didn't run the other test files, and bun scripts/gate.ts --fix rewrapped comments in one file, which is in the commit.

Check of the signed-out bodies. Neither page has a per-visitor value in what a signed-out visitor receives, so both are shared.

  • /pricing: the order form carries no CSRF token or nonce. The forge_order cookie only changes the page when a cookie is sent, and a request with any cookie is never given the shared copy.
  • /templates: the list, the "what it holds" rows and the usage counts are the same for every signed-out visitor.
  • Query strings: ?name= and ?q= change the body, so they are part of the address the edge keys on.

Tests. The new test fetches each page twice signed out with different x-request-id values and asserts the bodies are byte-identical. It also asserts s-maxage=60 and Vary containing EDGE_VARY signed out, and no s-maxage with the admin cookie or with a stray cookie. It calls sharedCache directly too. I put it in test/web-budget.test.ts next to the existing / and /explore edge tests rather than creating a new file.

Not done. Per atlas's note, the edge reports cf-cache-status: DYNAMIC even for /. These pages won't actually be kept until the owner adds an edge cache rule. This change proves the headers and the byte-identical bodies, not a cache hit.

To try. Run curl -sI <app>/pricing and curl -sI <app>/templates and read cache-control and vary. Repeat with -H 'cookie: a=b' to see that s-maxage is gone.

Closes #14658

commented

A signed-out GET of /pricing or /templates now answers public, max-age=0, s-maxage=60, stale-while-revalidate=300, with Vary carrying EDGE_VARY. I changed sharedPath in src/http/edge_cache.ts and extended test/web-budget.test.ts. That test file and tsc pass; I didn't run the other test files, and bun scripts/gate.ts --fix rewrapped comments in one file, which is in the commit.

Check of the signed-out bodies. Neither page has a per-visitor value in what a signed-out visitor receives, so both are shared.

  • /pricing: the order form carries no CSRF token or nonce. The forge_order cookie only changes the page when a cookie is sent, and a request with any cookie is never given the shared copy.
  • /templates: the list, the "what it holds" rows and the usage counts are the same for every signed-out visitor.
  • Query strings: ?name= and ?q= change the body, so they are part of the address the edge keys on.

Tests. The new test fetches each page twice signed out with different x-request-id values and asserts the bodies are byte-identical. It also asserts s-maxage=60 and Vary containing EDGE_VARY signed out, and no s-maxage with the admin cookie or with a stray cookie. It calls sharedCache directly too. I put it in test/web-budget.test.ts next to the existing / and /explore edge tests rather than creating a new file.

Not done. Per atlas's note, the edge reports cf-cache-status: DYNAMIC even for /. These pages won't actually be kept until the owner adds an edge cache rule. This change proves the headers and the byte-identical bodies, not a cache hit.

To try. Run curl -sI <app>/pricing and curl -sI <app>/templates and read cache-control and vary. Repeat with -H 'cookie: a=b' to see that s-maxage is gone.

Approved

Clean, minimal change. Preview: signed-out /pricing and /templates answer public, s-maxage=60 with Vary carrying EDGE_VARY; with a cookie, private no-cache. Neither signed-out body carries a CSRF token or nonce (checked on the preview), and the cookie-only forge_order variation is never served from the shared copy. Test asserts both paths signed out/in, stray cookie, byte-identical bodies across request ids, and sharedCache directly.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs