Agent view — served from /content-negotiation.md.

Guide · updated September 2026

What is content negotiation for AI, and why does it cut costs by 90%?

Content negotiation means serving a clean markdown version of a page when a program requests one, instead of the full HTML a browser needs. It typically reduces what an AI pays to read the page by 80–99%, which makes your content cheaper to use than a competitor’s. Around 3.9% of sites support it (Cloudflare, April 2026).

How does an AI ask for markdown?

With a standard HTTP header. The client sends Accept: text/markdown and a server that supports negotiation returns markdown with a matching content-type. A server that does not simply returns HTML and the client makes do.

the request and the ideal response
$ curl -H "Accept: text/markdown" https://code4x.com/registry -I

HTTP/2 200
content-type: text/markdown; charset=utf-8
vary: accept
link: </llms.txt>; rel="alternate"; type="text/plain"

The Vary: accept header matters and is the most commonly omitted piece. Without it, caches and CDNs will happily serve your markdown to a browser or your HTML to an agent.

How much does it actually save?

On a typical marketing page, between eighty and ninety-nine per cent of what an AI reads is markup it does not need.

HTMLMarkdownChange
Page weight312 KB11 KB−96%
Estimated tokens~78,400~2,750−96%
Useful contentidenticalidentical

The second row is the one that matters commercially. An agent working within a context budget will read more of a cheap source and less of an expensive one, and when it is choosing between two sites that say roughly the same thing, cost is a real tiebreaker.

It also helps you directly: a page that fits comfortably in context gets summarised accurately, while a page that has to be truncated gets summarised from whatever fragment survived.

How do I implement content negotiation?

Next.js

middleware.ts
export function middleware(req: NextRequest) {
  const accept = req.headers.get('accept') || ''
  if (accept.includes('text/markdown')) {
    const url = req.nextUrl.clone()
    url.pathname = `${req.nextUrl.pathname}.md`
    return NextResponse.rewrite(url)
  }
}

nginx

nginx.conf
location / {
  if ($http_accept ~* "text/markdown") {
    rewrite ^(.*)$ $1.md break;
  }
  add_header Vary Accept;
}

Cloudflare Workers

worker.js
export default {
  async fetch(request) {
    const accept = request.headers.get('Accept') || ''
    const url = new URL(request.url)
    if (accept.includes('text/markdown')) url.pathname += '.md'
    const res = await fetch(url, request)
    const out = new Response(res.body, res)
    out.headers.set('Vary', 'Accept')
    return out
  }
}

All three assume a markdown version exists at the same path with a .md suffix. If you write in markdown already, that is close to free. If you write in a CMS, generate the markdown at build time from the same source your HTML comes from — never by scraping your own HTML, which reintroduces every problem you are solving.

Which tools send this header today?

Coding assistants led here. Claude Code, Cursor and OpenCode send it natively, which makes documentation sites the highest-value early adopters. Several crawlers and fetch libraries have followed.

Adoption on the serving side remains around four per cent of sites, so the competitive window is unusually wide for something this cheap to implement.

Where this is contested

The savings are real and easy to verify yourself; whether they translate into more citations is not established. The mechanism is plausible — cheaper sources get read more completely — but we are not aware of a controlled study, and we would rather say so.

The honest case for implementing it is that it is a few hours of work, it makes your content demonstrably easier to consume, and it costs you nothing if the citation effect turns out to be small. That is a different argument from a guaranteed return, and it is the one we make.

Questions

Frequently asked

What is Accept: text/markdown?

An HTTP request header a client sends to ask for a markdown version of a page instead of HTML. Servers that support content negotiation return markdown with a matching content-type; servers that do not return HTML as normal.

How much does serving markdown save an AI crawler?

Typically 80-99% of page weight and token count on a normal marketing page. A 312 KB HTML page commonly reduces to around 11 KB of markdown containing the same information.

Do I need the Vary: Accept header?

Yes. Without it, caches and CDNs may serve markdown to browsers or HTML to agents, because they will not know the response varies by request header. It is the most commonly omitted part of an otherwise correct implementation.

Should I generate markdown from my HTML?

No. Generate it at build time from the same source your HTML comes from. Converting your own rendered HTML back to markdown reintroduces the markup problems you are trying to eliminate.

How many sites support content negotiation for AI?

Around 3.9% as of April 2026, according to Cloudflare. Adoption is concentrated in documentation sites, because coding assistants were the first tools to send the header natively.

Related

Next

JavaScript & AI crawlers

Why your React site may be invisible.

Read →

llms.txt

What it is, and whether it works.

Read →

All 55 checks

The full technical reference.

Read →

See how AI reads your site

Eight checks against your domain in about fifteen seconds. No email.