Why adding llms.txt and Accept: text/markdown cut our origin bot load in half
Two posts on HN today paired together nicely: one on implementing agent-web specs and another noting that 9 in 10 requests to their site now come from bots.
We checked our own docs logs last month and saw the exact same thing: coding agents and web-fetch tools were hammering our Next.js SSR routes, downloading megabytes of JS bundles and navbar HTML just to extract a 400-word API reference.
Worse, noisy HTML-to-markdown scrapers kept hallucinating links from our footer into code snippets.
Give agents plain markdown on purpose
Instead of fighting bot user-agents with aggressive CAPTCHAs on public docs, we added two tiny endpoints:
/llms.txtat the root listing our core docs URLs as clean.mdlinks.- Content negotiation (
Accept: text/markdown) in middleware so any agent that asks for markdown gets a CDN-cached plain text response with zero SSR rendering.
ts// Next.js middleware snippet: serve pre-built markdown when agents ask for it export function middleware(req: NextRequest) { const accept = req.headers.get("accept") || ""; if (accept.includes("text/markdown") && req.nextUrl.pathname.startsWith("/docs/")) { const mdUrl = req.nextUrl.clone(); mdUrl.pathname = `/raw-md${req.nextUrl.pathname}.md`; return NextResponse.rewrite(mdUrl); } }
Origin SSR load dropped noticeably, and agents stopped misreading our sidebar links as API parameters.