Skip to content

Fix unstyled docs pages: serve 304s for cached assets - #754

Merged
kristin-kronstain-brown merged 1 commit into
mainfrom
kkb-fix-docs-304
Nov 23, 2026
Merged

kristin-kronstain-brown merged 1 commit into
mainfrom
kkb-fix-docs-304

Conversation

@kristin-kronstain-brown

Copy link
Copy Markdown
Contributor

Problem

Since #752, docs pages on kagent.dev load without CSS or JavaScript after the first visit. A hard refresh fixes one page, and the next link breaks again. The browser console shows SRI failures, with the same computed hash for every asset.

Cause

worker.mjs handles every /docs/* request. For a file request, it calls env.ASSETS.fetch(request) and returns the result only if exact.ok is true. When the browser already has a file cached, it sends If-None-Match, and ASSETS answers 304 Not Modified. Because ok only covers 200-299, the worker treated the 304 as a miss and fell through to Next.js, which returned its 404 HTML page for every CSS and JS file.

To reproduce on production:

U=https://kagent.dev/docs/js/glossary.js
ET=$(curl -sI "$U" | grep -i '^etag' | cut -d' ' -f2- | tr -d '\r')
curl -s -o /dev/null -w '%{http_code}\n' -H "If-None-Match: $ET" "$U"   # 404, expected 304

Fix

Return the ASSETS response when it is ok or a 304.

The other sites that use the same content negotiation (agentgateway.dev, kgateway.dev, aregistry.ai, ambientmesh.io) run it as a Cloudflare Pages _worker.js and already return 304 correctly.

Testing

Not yet run locally with npm run preview:worker. After deploy, the curl above should print 304.

🤖 Generated with Claude Code

Signed-off-by: Kristin Brown <kristin.brown@solo.io>
@github-actions

Copy link
Copy Markdown
Contributor

Docs preview

Link Points at
Branch preview The newest push to this branch. Updates in place.
Commit preview ab2cda8 only. Frozen.

Both are uploaded Worker versions and serve no production traffic.

@kristin-kronstain-brown
kristin-kronstain-brown merged commit 6e932df into main Nov 23, 2026
2 checks passed
sebbycorp added a commit that referenced this pull request Nov 23, 2026
Brings in the worker fix for cached /docs files (#754), so the preview
stops answering revalidation requests with 404.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FeiRMhsi2TebnCBPxxRCT1
Signed-off-by: Sebastian Maniak <sebastian@maniak.io>
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.

2 participants