Serve Markdown to AI Agents with Accept Headers
TL;DR Highlight
Serve Markdown from the same URL when clients send Accept: text/markdown.
Who Should Read
Backend or web developers whose docs are read by agents or RAG pipelines and who want fewer wasted tokens and less noise
Core Mechanics
- One URL, two responses
- Browsers get HTML, and clients sending Accept: text/markdown get Markdown.
- It uses HTTP content negotiation, where a request header picks the response format.
- Claimed token savings
- Markdown drops nav, styles, scripts and layout wrappers.
- Agents spend context on your prose instead of your DOM.
- Less noise for RAG
- Ads, related-content rails and modal overlays disappear.
- The text a RAG pipeline embeds gets a better signal-to-noise ratio.
- Claimed faster first token
- There is less to fetch, parse and stuff into the context window.
- The model starts thinking sooner.
- A correctness checklist
- Check that Accept: text/markdown returns Markdown and that Vary: Accept is set.
- Also check that unsupported types get 406 and q-values are honored.
- Recipes and a support matrix
- Config recipes cover Nginx, Caddy, WordPress, Laravel, Rails, Next.js, Astro, Express, Go, Django and more.
- A status table shows which AI agents send this header.
Community Reactions
- Caching concerns raised
- Commenters quoted Roy Fielding and Simon Willison saying Accept-based negotiation is bad for caching.
- They noted Cloudflare CDN may serve cached JSON to an HTML client or vice versa.
- No agents use it yet
- Some said they won't adopt it until a top AI chatbot sends this header.
- Others asked what sites get in return.
- Harnesses should convert
- Some argued the agent harness should convert HTML to Markdown itself.
- They said the whole web shouldn't be rewritten for that.
- Trust and security worries
- Some said bots can't trust that the Markdown matches the HTML.
- Others warned about prompt injection and feeding LLMs bad content.
How to Apply
- Check your site's headers with curl
- Today, run curl -sI -H "Accept: text/markdown" <URL> and check Content-Type and Vary.
- Fetch the body with curl -s and see whether HTML still comes back.
- Add Vary: Accept and 406 handling
- When adding a Markdown variant, always set Vary: Accept on responses.
- Return 406 for unsupported types.
- Test CDN caching first
- Before shipping, verify the CDN caches responses separately per Accept header.
- If it doesn't, serve Markdown from a separate URL such as .md.
Try It
# Paste into a terminal (replace with your site URL)
curl -sI -H "Accept: text/markdown" {{URL}}
# Fetch the Markdown body
curl -s -H "Accept: text/markdown" {{URL}} | head -50
# Compare with a normal HTML request
curl -sI -H "Accept: text/html" {{URL}}Terminology
Related Papers
A Beginner's Guide to Local AI with Inkling, Qwen, and Unsloth
Install Unsloth Desktop, load a quantized Qwen model, and share a private ChatGPT-like AI on your home LAN.
Muru – AI-assisted Rust server for Python apps by mod_WSGI's creator
mod_wsgi's creator is building Muru, an AI-assisted Rust ASGI/WSGI server, documenting it in public
87% of the Anthropic power will come from gas and 11% from coal in 2028
Analysis of Anthropic's contracted data centers: 87% gas, 11% coal power in 2028
Anthropic’s Nasdaq debut
Anthropic listed on Nasdaq and closed its first day below its opening price.
OpenAI still has a WebRTC Problem
WebRTC drops late audio, hurting voice AI; MoQ retransmits and buffers instead
Gemini 4 Neon
Gemini 4 Neon cuts cost per task 32% versus Carbon, at $3 input and $15 output per million tokens
AI is killing All About Berlin
After Google AI Overviews, a Berlin guide site lost 70-75% of its traffic.
Not Everything Needs an LLM
PostHog used small decision models to skip 98.7% of expensive LLM calls