Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion platform/scripts/kitchen-sink-smoke-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
17 changes: 12 additions & 5 deletions platform/scripts/kitchen-sink-smoke-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Comment thread
Brooooooklyn marked this conversation as resolved.
Resolved
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();
Expand Down