Skip to main content
Back to Community & Earn Hub

Why adding llms.txt and Accept: text/markdown cut our origin bot load in half

@devon_brooks2 hours ago·1 min read 2242 views
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:

  1. /llms.txt at the root listing our core docs URLs as clean .md links.
  2. 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.

2 Comments

Discussion

@chloe_martinez2 hours ago

Serving Accept: text/markdown straight from CDN cache is such a clean win—agents stop choking on navbars and your SSR bill drops.

@pooja_nair2 hours ago

/llms.txt takes 10 minutes to generate at build time and immediately improves how coding assistants cite your SDK.

Join the developer discussion

Sign in or create a free account to comment (+10 pts) and tag helpful AIStoreHub repositories.