# crawler ssr vs. spa visibility

- Status: `experiment`
- Track: [crawler visibility, model cutoffs & quality evals](https://aifoc.us/labs/platform-observability/)
- Layer: 8. Crawler Visibility, Model Cutoffs & Quality Evals
- Updated: 2 December 2026
- Live demo: https://crawler-ssr-vs-spa-visibility.kinlan-test.workers.dev
- Source: https://github.com/PaulKinlan/crawler-ssr-vs-spa-visibility

## Inspired by

- [does a url in a prompt steer an llm](https://aifoc.us/influencing-model-output-with-urls/)
- [hyper content negotiation](https://aifoc.us/hyper-content-negotiation/)
- [please mind the model gap](https://aifoc.us/please-mind-the-model-gap/)

## Why this matters

Non-rendering HTTP crawlers (`ClaudeBot`, `GPTBot`, `CCBot`) read raw wire HTML without executing client-side JavaScript. When a page ships an empty [SPA](https://developer.mozilla.org/en-US/docs/Glossary/SPA) shell (`<div id="root"></div>`) and populates prose only after scripts run, those crawlers record zero visible words—leaving the page invisible in training snapshots and non-rendering retrieval pipelines.

## What this opens up

Exposing JS-only crawler blind spots before a page ships. Teams can inspect raw non-JS HTML side by side with a live browser render, audit any public HTTPS URL behind an [SSRF](https://owasp.org/www-community/attacks/Server_Side_Request_Forgery) guard, and catch false positives where naive regexes misclassify streaming [SSR](https://web.dev/articles/rendering-on-the-web) pages as empty shells.

## How the tests work

1. Click **Audit Empty SPA Shell** vs. **Audit Pure SSR** to compare `0` raw wire words inside `#root` against ~190 rendered browser words in the side-by-side preview iframe.
2. Run **Trigger Streaming Falsification** (`/fixtures/streaming-falsify`) to inspect how an empty `#root` paired with deferred `<template hidden>` prose and React Flight payloads fools naive regex shell detectors.
3. Switch to **Public HTTPS URL** to fire blocked SSRF probes (`169.254.169.254`, `127.0.0.1`, `[::1]`, `http://`) and audit a real public HTTPS page, or switch to **Paste Raw HTML** to test local snippets with `X-Robots-Tag` and `Content-Usage` headers.
4. Run **Matrix All 4 Fixtures** to compare wire bytes, visible words, `<template>` words, hydration payload bytes, and verdicts in one table.


## Hypothesis

- **Claim:** Fetching raw wire HTML without executing JavaScript and parsing it with streaming `HTMLRewriter` for empty application mounts (`#root`, `#app`, `#__next`, `<app-root>`) plus visible body word count accurately predicts non-rendering crawler blindness.
- **Confirms it:** Auditing `/fixtures/empty-spa` against `/fixtures/ssr` records `0` visible non-JS wire words inside `<div id="root"></div>` while the rendered browser iframe displays ~190 words after `/fixtures/empty-spa.js` runs—mirroring empirical findings in [URLs in Models](/influencing-model-output-with-urls/) (`6%` bare-URL recall on 31 client-rendered pages vs. `55%` on 60 server-rendered sources; `0.45%` empty-mount floor across `1.04M` Common Crawl pages, rising to `2.5%–2.8%` among top-10k domains).
- **Bounds or disproves it:** `/fixtures/streaming-falsify` pairs an empty `#root` mount with deferred server-rendered prose inside `<template hidden>` and serialized React Flight / `__NEXT_DATA__` payloads—causing naive empty-mount regexes to emit false-positive SPA shell verdicts and naive tag-strippers to count JSON keys as visible prose.


## Under the hood

[Crawler SSR vs. SPA Visibility](https://crawler-ssr-vs-spa-visibility.kinlan-test.workers.dev) ([GitHub](https://github.com/PaulKinlan/crawler-ssr-vs-spa-visibility)) runs a Cloudflare Worker with two core modules: an SSRF-hardened fetcher (`src/ssrf.ts`) and a streaming HTML auditor (`src/auditor.ts`). Before any remote request leaves the edge, `src/ssrf.ts` enforces `https://` on port 443, rejects private RFC 1918, loopback, CGNAT, link-local, metadata (`169.254.169.254`), and IPv6 literals, validates every `redirect: "manual"` hop, and caps wire reads at 512 KiB and 8 seconds.

`src/auditor.ts` streams raw wire bytes through Cloudflare `HTMLRewriter` (with a parity state-machine fallback in Node unit tests) to separate visible body text from `<script>`, `<style>`, `<svg>`, `<noscript>`, and `<template>`/`[hidden]` regions, quantify hydration payload bytes, detect empty SPA mounts, and compare naive regex detection against streaming-aware classification. The Worker also hosts four live fixtures (`/fixtures/ssr`, `/fixtures/hydration-heavy`, `/fixtures/empty-spa`, `/fixtures/streaming-falsify`) so the workbench can audit the raw response while rendering the exact same URL inside a sandboxed same-origin iframe.


## Key terms & further reading

- [SSR vs. CSR (Server-Side vs. Client-Side Rendering)](https://web.dev/articles/rendering-on-the-web) — SSR sends finished HTML prose in the initial HTTP response; CSR sends a minimal shell and builds visible text in the browser with JavaScript.
- [Empty SPA shell](https://developer.mozilla.org/en-US/docs/Glossary/SPA) — A single-page app response containing only an empty mount node such as `<div id="root"></div>` until client scripts execute.
- [Cloudflare HTMLRewriter](https://developers.cloudflare.com/workers/runtime-apis/html-rewriter/) — A streaming edge HTML parser that inspects tags and text chunks directly on the wire without executing JavaScript.
- [Hydration & React Flight payloads](https://react.dev/reference/react-dom/client/hydrateRoot) — Serialized state blobs (`__NEXT_DATA__`, `__NUXT__`, `self.__next_f.push`) embedded inside `<script>` tags so client code can attach interactivity.
- [SSRF (Server-Side Request Forgery) guard](https://owasp.org/www-community/attacks/Server_Side_Request_Forgery) — URL and redirect validation that blocks server-side fetchers from reaching loopback, RFC 1918, CGNAT, or cloud metadata addresses.
- [X-Robots-Tag & IETF aipref (Content-Usage)](https://datatracker.ietf.org/wg/aipref/about/) — HTTP response headers communicating indexing and AI training preferences to automated crawlers.

## Open questions to iterate on

- How accurately can streaming HTML parsers separate real server-rendered streaming `<template>` chunks from hidden metadata or unused hydration JSON?
- When a site cannot rewrite its SPA shell immediately, does `Accept: text/markdown` content negotiation close the crawler visibility gap without duplicating URLs?

## Iteration log

- **2026-12-02:** Deployed SSRF-hardened Cloudflare Worker (`POST /api/audit-url`, `/api/audit-fixture`, `/api/analyze-html`) running streaming `HTMLRewriter` across four fixtures (`SSR Content-Rich`, `Hydration-Heavy RSC/JSON`, `Empty Client SPA Shell`, `Streaming/Deferred Ambiguous`) with live side-by-side raw crawler vs. browser iframe previews.

## Primitives tested

- `Cloudflare HTMLRewriter`
- `Non-JS HTTP Crawler Audit`
- `SSRF-Hardened Fetcher`
- `DOM vs. Wire Word Diff`

## Connected labs in other tracks

- [hyper content negotiation lab](https://aifoc.us/labs/web-protocols/hyper-content-negotiation-lab/) — Tests RFC 9110 `Accept: text/markdown` delivery as a compact server-rendered representation.
- [model-gap live conformance probe](https://aifoc.us/labs/platform-observability/model-gap-live-harness/) — Shows how crawler invisibility and stale training snapshots compound into outdated model code.
- [evidence distiller & eval harness](https://aifoc.us/labs/platform-observability/evidence-distiller-eval-harness/) — Distills rendered browser DOM and runtime fault state under 4 KB for automated eval scoring.

---
Canonical: https://aifoc.us/labs/platform-observability/crawler-ssr-vs-spa-visibility/
