Skip to content

Assert asset caching on the response, not the browser cache. - #319

Merged
Brooooooklyn merged 2 commits into
mainfrom
fix/smoke-test-asset-cache
Sep 14, 2026
Merged

Brooooooklyn merged 2 commits into
mainfrom
fix/smoke-test-asset-cache

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

The staging smoke test fails 1 of its 11 assertions, and the assertion is measuring the wrong thing.

What failed

run 34809396966 (main)
✖ 1 — home SSR + asset caching
    AssertionError: Cache-Control includes immutable (got: no-store)   kitchen-sink-smoke-test.ts:152

The other ten assertions pass (SPA nav, layout, DB, KV, R2, env, queues, auth, cron, ISR). The app is fine; the check is not.

Why the check was wrong

It read cache-control from a HEAD issued after the page load:

const res = await fetch(url, { method: 'HEAD' });

Two things make that meaningless as an asset-caching assertion:

  1. It reads the stored entry, not the network. The page load already fetched that asset, so a conditional HEAD is answered from (or revalidated against) what the browser stored, and the test reads whatever that entry says — not the response the platform just produced.
  2. HEAD is outside the contract it claims to test. The dispatch edge cache stamps public, max-age=31536000, immutable on GETs to hashed paths only (platform/packages/dispatch/src/index.ts:737); a HEAD falls through the generic path (the code says so explicitly at index.ts:747-750). A HEAD also can't be stamped by the Cache-Control pass, which is applied to cache-eligible GET responses.

The fix

Fetch with cache: 'no-store' so the request must go to the network, and assert the status too, so a missing or fallback-served asset fails with the status in the message rather than only a header mismatch:

const asset = await page.evaluate(async (url) => {
  const res = await fetch(url, { cache: 'no-store' });
  return { status: res.status, cacheControl: res.headers.get('cache-control') || '' };
}, assetUrl);

assert.equal(asset.status, 200, `asset GET succeeds (got ${asset.status})`);
assert.ok(asset.cacheControl.includes('immutable'), ...);

Still an in-browser fetch (not curl) — CF edge cache rules differ for browser and non-browser clients.

The manual runbook carried the same HEAD probe (platform/scripts/kitchen-sink-smoke-test.md, test 1), so an agent following it could report the same false failure. It now documents a sync XHR GET with a cache-busting query parameter — agent-browser eval is sync-only, so fetch(..., { cache: 'no-store' }) is not available there — plus the snippet and the expected header.

Verified

  • platform-smoke-test.yml dispatched on this branch: all 11 assertions pass on staging.
  • The same probe against production returns 200 + public, max-age=31536000, immutable, including the runbook's sync-XHR variant.

Not in this PR

HEADs to hashed assets are not stamped immutable when the origin answers 304 (dispatch only stamps response.ok, i.e. 2xx — index.ts:913, index.ts:942), and the WFP asset fallback omits Cache-Control entirely on a HEAD. Both are unexercised by the suite today. Left alone here: the browser asset path is GET, where the contract holds.

Test 1 read `cache-control` from a HEAD issued after the page load, so it
reported the entry the browser had already stored instead of the response the
platform produced. The immutable stamp lives on gets to hashed paths, so a
conditional HEAD asserted a contract it never measured.

Fetch with `cache: 'no-store'` for a network response, and assert the status
too, so a missing or fallback-served asset fails with the status in the message.
@cursor

cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_a61c2e51-d2f6-4dea-a16d-9a00fd6d25da)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-14T05:56:40.792881Z e5592ce New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d033544098

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

The runbook told agents to HEAD a hashed asset — the probe this branch
replaces in the automated test — so following it could report the same false
failure. Document the sync XHR get instead (cache-busted, because
`agent-browser eval` is sync-only) and the header to expect.
@cursor

cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_7e06e1ff-7867-4cf2-b0e1-b0b8948162c3)

@Brooooooklyn
Brooooooklyn merged commit cfb7aba into main Sep 14, 2026
16 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/smoke-test-asset-cache branch September 14, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant