# hyper content negotiation lab

- Status: `experiment`
- Track: [content negotiation, signed citations & attribution](https://aifoc.us/labs/web-protocols/)
- Layer: 4. Network Stack, Content Negotiation & Protocols
- Updated: 1 December 2026
- Live demo: https://hyper-content-negotiation-lab.kinlan-test.workers.dev
- Source: https://github.com/PaulKinlan/hyper-content-negotiation-lab

## Inspired by

- [hyper content negotiation](https://aifoc.us/hyper-content-negotiation/)

## Hypothesis

- **Claim:** Standard RFC 9110 `Accept` negotiation (`Vary: Accept`) on a single canonical URL shrinks automated retrieval payloads significantly without breaking human HTML browsing or duplicating URL trees.
- **Confirms it:** `text/markdown` and JSON-LD representations measure 50–85% fewer bytes and estimated tokens than the full `text/html` representation while preserving `Vary: Accept` and alternate `Link` discovery headers.
- **Falsifies or bounds it:** Fine-grained custom modality headers (such as `Accept-Prompt`) fragment CDN caches (`Vary` cache collapse) or reveal too much fingerprinting surface.

> **Why this exists:** Returning full styled HTML pages to automated readers wastes tokens on navigation chrome and forces brittle scraping instead of structured data. This lab tests real HTTP `Accept` content negotiation (`Vary: Accept`) returning HTML, Markdown, JSON-LD, or JSON cleanly from one canonical URL.


## What this lab tests

Serving monolithic rendered HTML to both visual browsers and automated retrieval pipelines bloats token budgets and mixes chrome with primary content. Does standard [RFC 9110 `Accept` content negotiation](https://www.rfc-editor.org/rfc/rfc9110#section-12.5.1) solve this from one canonical URL?

[Hyper Content Negotiation Lab](https://hyper-content-negotiation-lab.kinlan-test.workers.dev) ([GitHub](https://github.com/PaulKinlan/hyper-content-negotiation-lab)) serves canonical [`/docs/hyper-content-negotiation`](https://hyper-content-negotiation-lab.kinlan-test.workers.dev/docs/hyper-content-negotiation) resources plus an SSRF-hardened `/negotiate?url=https://...` proxy, responding with `text/html`, compact `text/markdown`, `application/ld+json` ([Schema.org](https://schema.org/Article)), or `application/json` while setting `Vary: Accept`, `Link` alternates, byte counts, and estimated token reductions.


## Open questions to iterate on

- Where should negotiation draw the line between coarse standard media types (`text/markdown`, `application/ld+json`) and parameter-heavy headers?
- How well do SSRF-guarded negotiation proxies interact with sites that return different content to bots than browsers?

## Iteration log

- **2026-12-01:** Shipped `/docs/*` canonical endpoint, SSRF-hardened `/negotiate` HTTPS inspector, byte/token savings breakdown, and code blueprint.
- **2026-12-01:** Reordered workbench around hypothesis/confirm/falsify signals with live `Accept-Prompt` cache-collapse testing, CSP-safe syntax highlighting across all wire/code views, 700px responsive layout fixes, and `no-cache` static asset headers.

## Primitives tested

- `HTTP Accept Header`
- `Vary: Accept`
- `Link Headers`
- `text/markdown`
- `application/ld+json`

## Connected labs in other tracks

- [attribution & metering protocol lab](https://aifoc.us/labs/web-protocols/attribution-metering-lab/) — Pairs compact content negotiation with signed referral/usage receipts.
- [signed web citations](https://aifoc.us/labs/web-protocols/signed-web-citations/) — Signs negotiated content payloads with RFC 9421 HTTP Message Signatures.

---
Canonical: https://aifoc.us/labs/web-protocols/hyper-content-negotiation-lab/
