Heuristic:1broseidon Ketch Adaptive Browser Escalation
| Knowledge Sources | |
|---|---|
| Domains | Crawl, Optimization, Heuristic_Detection |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
Per-host JS-shell ratio that promotes a whole host to browser rendering only after a 10-page sample shows > 80% shells, avoiding per-page browser cost on mostly-static sites while auto-fixing heavy SPA hosts.
The Insight (Rule of Thumb)
- Action: During a crawl, record each HTML page's JS-detection result per host. When a host's shell ratio exceeds the threshold, force-browser every subsequent page on that host (after classifying the HTTP response — PDFs never enter the browser path).
- Value: Threshold = `total ≥ 10` pages and `shells / total > 0.8`. Below 10 sampled pages the host is left on the static path; the 0.8 ratio tolerates the occasional static page on an SPA site.
- Trade-off: A host that flips to mostly-shell after the sample is already taken still pays one render per shell page until the ratio crosses 0.8; a host with a few shell pages among many static ones never escalates and those shells return garbage. The threshold favours crawl speed over per-page completeness.
- Compatibility: Even when the heuristic says render, `ScrapeConditional` runs first so non-HTML content (PDFs) is never sent to the browser. Requires a configured browser (`scraper.HasBrowser()`); without one the heuristic is inert and shells are cached as `SourceHTTPShell`.
Reasoning
A crawl walks whole sites, and a per-page "is this a shell?" check would render every page on an SPA site — fine for that site, but a crawl of a mostly-static site with one React page would burn one render per page for nothing. The per-host aggregate turns the per-page detector into a site-level decision: sample 10, then commit to rendering the rest if the site is clearly client-rendered.
The 80% bar is high enough that a single static landing page among SPA routes doesn't block escalation, and low enough that a site with a genuine mix stays on the cheap path. The 10-page minimum prevents a hot streak of 3 shells from locking a host into rendering before there's enough evidence.
As the code comment on `shouldForceBrowser` (`crawl/crawl.go:348-361`) notes: the per-host stats gate keeps browser renders bounded across a whole crawl rather than deciding per page.