Skip to content

fix: drop ua-based markdown switching - #71

Merged
pamelachia merged 1 commit into
mainfrom
pamela/drop-ua-markdown-switching
Jul 9, 2026
Merged

pamelachia merged 1 commit into
mainfrom
pamela/drop-ua-markdown-switching

Conversation

@pamelachia

Copy link
Copy Markdown
Contributor

Summary

The middleware served markdown based on user-agent matching, but markdown responses only declare Vary: Accept, so the CDN cache key ignores the user agent and whichever variant is computed first gets cached for every client. I observed this live as deterministic variant poisoning: byte-identical ChatGPT-User requests received text/html on GET and text/markdown on HEAD for the same cached URL. This change removes the UA branch so content varies only by the Accept header, which makes the declared Vary truthful and the poisoning structurally impossible. Clients that want markdown still get it via Accept negotiation or explicit .md URLs; separately, the ChatGPT-User agent's reader currently hard-fails on markdown it receives via UA matching (details in GROWTH-973), so consistently serving it the fully server-rendered HTML also fixes readability in that assistant.

Changes

  • Remove LIVE_FETCH_UA_RE/isLiveFetchAgent from src/start.ts; bare URLs serve markdown only when the Accept header prefers it, explicit .md URLs unchanged

Testing

Tested locally:

  • Dev-server matrix: ChatGPT-User and Claude-User UA GETs return text/html; Accept: text/markdown returns text/markdown; GET and HEAD agree
  • Claude's real fetcher keeps receiving markdown (it sends Accept: text/markdown, text/html, */*, which wins negotiation)

Verify in production post-deploy (dev harness cannot exercise these):

  • GET/HEAD content-type consistency on a previously cached blog URL
  • Explicit .md URLs still serve markdown

Linear

  • fixes GROWTH-973

Signed-off-by: Pamela Chia <pamelachiamayyee@gmail.com>
@pamelachia pamelachia self-assigned this Jul 9, 2026
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
multigres-site Ready Ready Preview, Comment Jul 9, 2026 9:41am

Request Review

@pamelachia
pamelachia merged commit 6a731a2 into main Jul 9, 2026
4 checks passed
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