Header-Driven Context Segmentation: Using HTTP Vary Directives to Dynamically Filter JSON-LD @graph Payloads for Specific AI Crawler Identities
A concise guide on using HTTP Vary to serve crawler‑specific JSON‑LD @graph fragments, reducing token waste for GPTBot, ClaudeBot, and PerplexityBot.
- Vary: User-Agent enables edge caches to store separate JSON‑LD sub‑graphs per AI crawler, avoiding token bloat.
- Middleware can whitelist schema.org types per crawler, filter the @graph, and preserve SEO integrity.
- Novicite audits verify that each frontier engine receives the intended filtered markup and flags drift.
Why Conditional JSON‑LD Matters for LLM Crawlers
When GPTBot requests a page, the server can inspect the User‑Agent header and return a JSON‑LD @graph that contains only the Product and Offer types needed for e‑commerce queries, omitting Event and FAQ nodes. This reduction directly lowers the number of tokens the model must process, improving latency and cost without altering the underlying structured data model.
The server implements a lightweight middleware that maps known crawler identifiers—GPTBot, ClaudeBot, PerplexityBot—to a whitelist of schema.org types. After the base @graph is generated, the middleware filters out disallowed nodes, serializes the reduced graph, and sets Vary: User-Agent so downstream caches store separate variants.
- Define a whitelist per crawler in a configuration file or database.
- Filter the generated @graph before serialization based on the whitelist.
- Add Vary: User-Agent to the response to trigger cache key diversification.
Implementing Vary‑Based Payload Segmentation
In an Nginx or Apache edge, the add_header directive can inject Vary: User-Agent and route the request to a FastCGI script that receives the header as an environment variable. The script then selects a pre‑computed JSON‑LD fragment from disk or a key‑value store, merges it with the page’s core markup, and streams the result.
If the infrastructure uses a CDN such as Cloudflare Workers, the same logic can be expressed in JavaScript: read request.headers.get('User-Agent'), compare against a Set of crawler signatures, and respond with a cached variant keyed by the User-Agent fingerprint. Because the Vary header is respected by most modern CDNs, the edge cache will automatically keep distinct copies for each AI crawler.
- Use add_header Vary "User-Agent" in the web server configuration.
- Implement a fast lookup (e.g., Redis hash) of crawler → schema whitelist.
- Leverage CDN edge scripts to avoid round‑trips to origin for each variant.
Cache Invalidation and Auditing with Novicite
Novicite’s visibility auditor can query the twelve frontier engines—ChatGPT, Claude, Perplexity, Google AI Overviews, Gemini, Copilot, Grok, and others—to verify that each engine receives the intended JSON‑LD subset. The tool parses the returned @graph, matches schema.org types against the crawler whitelist, and flags mismatches for remediation.
When a schema change occurs, the Vary‑based pipeline must purge the old variant from both origin and CDN caches. Using the IndexNow protocol, Novicete can ping each engine’s endpoint with the updated URL, and the auditor can confirm that the new filtered @graph propagates within the typical re‑index window of a few hours, as described in Google’s crawl‑rate documentation.
- Run Novicite audits after each deployment to catch unintended schema exposure.
- Automate cache purge via CDN APIs whenever the whitelist is updated.
- Integrate IndexNow pings into the CI pipeline to accelerate re‑indexing.
Frequently Asked Questions
Do I need separate /llms.txt files for each AI crawler?
No. The Vary‑based approach filters JSON‑LD at request time, so a single /llms.txt can describe the full schema set while each crawler receives only its relevant subset.
Will varying on User-Agent hurt SEO for traditional search engines?
Standard search engines ignore the Vary: User-Agent header for HTML content, so they receive the full markup. Ensure the Vary header is limited to JSON‑LD responses to avoid unintended fragmentation.
Benchmark your domain across ChatGPT, Perplexity & Claude
Inspect live AI citations, bot crawler telemetry, and schema readiness in a single pass.