From d033544098f5abb7c65e33e77c87677e83793a81 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Mon, 14 Sep 2026 13:46:34 +0800 Subject: [PATCH 1/2] Assert asset caching on the response, not the browser cache. 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. --- platform/scripts/kitchen-sink-smoke-test.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/platform/scripts/kitchen-sink-smoke-test.ts b/platform/scripts/kitchen-sink-smoke-test.ts index 1aa7532cc..bb6c04197 100644 --- a/platform/scripts/kitchen-sink-smoke-test.ts +++ b/platform/scripts/kitchen-sink-smoke-test.ts @@ -143,15 +143,22 @@ void describe(`kitchen-sink smoke (${BASE})`, { concurrency: true }, () => { const assetUrl = `${BASE}/${assetMatch![1]}`; + // `cache: 'no-store'` makes this a NETWORK get, so the assertion reads the + // response the platform just produced. Reading the stored entry instead + // (plain HEAD after the page load, which is how this test used to run) + // reports whatever the browser cached earlier: the dispatch edge cache only + // stamps `immutable` on gets to hashed paths, so a conditional HEAD is both + // answered from the store and outside the caching contract under test. // Use in-browser fetch (not curl) — CF edge cache rules differ for browser vs non-browser - const cacheControl = await page.evaluate(async (url) => { - const res = await fetch(url, { method: 'HEAD' }); - return res.headers.get('cache-control') || ''; + 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( - cacheControl.includes('immutable'), - `Cache-Control includes immutable (got: ${cacheControl})`, + asset.cacheControl.includes('immutable'), + `Cache-Control includes immutable (got: ${asset.cacheControl})`, ); } finally { await ctx.close(); From e5592ce2eddb2494b1b086c38ce3dd5519255031 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Mon, 14 Sep 2026 13:54:22 +0800 Subject: [PATCH 2/2] Point the manual smoke runbook at a network get. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- platform/scripts/kitchen-sink-smoke-test.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/scripts/kitchen-sink-smoke-test.md b/platform/scripts/kitchen-sink-smoke-test.md index 82addcf6d..f6622413b 100644 --- a/platform/scripts/kitchen-sink-smoke-test.md +++ b/platform/scripts/kitchen-sink-smoke-test.md @@ -49,7 +49,20 @@ EVALEOF 1. Visit `/`. 2. Assert the page contains "Kitchen Sink" and "Auth" in its text. 3. Inspect the page's HTML source for hashed asset URLs (e.g. `.js` or `.css` files with hash in the filename). -4. Use an **in-browser sync XHR** (`XMLHttpRequest` via `agent-browser eval`) to HEAD-request one of those asset URLs and assert its `Cache-Control` header contains `immutable`. Do NOT use `curl` — Cloudflare edge cache rules rewrite headers differently for browser vs non-browser requests. +4. Use an **in-browser sync XHR** (`XMLHttpRequest` via `agent-browser eval`) to GET one of those asset URLs with a cache-busting query parameter, and assert its `Cache-Control` header contains `immutable`. Do NOT use `curl` — Cloudflare edge cache rules rewrite headers differently for browser vs non-browser requests. Do NOT use `HEAD`: the dispatch edge cache stamps `immutable` on `GET`s to hashed paths only, and a conditional `HEAD` is answered from the entry the browser already stored, so it reports `no-store` and looks like a failure. + + ```bash + agent-browser eval --stdin <<'EVALEOF' + const el = document.querySelector('script[src*="/assets/"]') || document.querySelector('link[href*="/assets/"]'); + const url = el.src || el.href; + const xhr = new XMLHttpRequest(); + xhr.open('GET', url + (url.includes('?') ? '&' : '?') + 'smoke=' + Date.now(), false); + xhr.send(); + xhr.status + ' ' + xhr.getResponseHeader('cache-control') + EVALEOF + ``` + + Expect `200 public, max-age=31536000, immutable`. ### 2. SPA navigation (no full reload)