Speculation Rules & Prerendering vs Back/Forward Cache (bfcache)
bfcache accelerates Back/Forward history traversal; Speculation Rules accelerates forward navigations.
Structured Comparison Matrix
| Dimension | Speculation Rules & Prerendering | Back/Forward Cache (bfcache) |
|---|---|---|
| Mental Model | Declarative JSON rules that prefetch or fully prerender predicted next navigations in a hidden browsing context, delivering near-instant 0 ms LCP on click. | In-memory cache snapshotting the full JS heap and DOM tree on outbound navigation to restore the page instantaneously on Back/Forward. |
| Maturity & Domain | Limited availability · Network & Performance Limited availability | Network & Performance |
| Prerequisites | Foundational primitive | Foundational primitive |
| When Not to Use | When not to use prerender: Avoid prerendering URLs with server-side side effects (logout links, add-to-cart GET endpoints) or pages heavy on WebGL/video memory. | When not to use bfcache: On banking or authenticated views displaying sensitive data after logout, enforce Cache-Control: no-store or clear sensitive DOM on pagehide. |
Engine Mechanics & Trade-Offs
Spawns a hidden background renderer tab to fetch, parse, and paint a predicted next navigation, swapping it atomically on click for near-zero LCP.
Key Pitfalls: Inflated analytics & ad beacons: Scripts that fire on DOMContentLoaded count phantom pageviews for every hovered link; gate telemetry on !document.prerendering and prerenderingchange. eagerness: immediate on large lists: Putting immediate on a 30-item catalog grid DDoS-attacks your own origin server on every page load.
Full JS heap and DOM tree preserved in RAM.
Key Pitfalls: unload listener in a third-party script: A single window.addEventListener('unload', ...) disables bfcache across the entire site. Stale state on return: A shopping cart or CSRF token restored from bfcache remains frozen; listen to pageshow (if (e.persisted)) to refresh volatile data.
Seen in Architecture Autopsies
Active tabs throw ChunkLoadError or corrupt local IndexedDB state after a production deploy.
After a routine IndexedDB version bump, every newly opened tab hangs indefinitely on the splash screen with zero network requests and no console errors.