demo · v138 · performance
Active Prerender Race: navigate while mutating
The edge case that matters for e-commerce: the user has triggered a prerender of /checkout, the cart-mutation POST fires and returns Clear-Site-Data: "prerenderCache", and then the user immediately clicks the link. The spec says: active prerenders are cancelled, not skipped — the navigation starts fresh as a regular load. This demo models that race with a controllable timeline.
Spec rule (Chrome 138): When
Clear-Site-Data: "prerenderCache" is received, any in-progress prerender for the cleared origin is cancelled. A subsequent navigation to the prerendered URL triggers a fresh fetch, not a speculative activation. Compare this to a prefetch hit, which is simply evicted.
Scenario:
Prerender /checkout
POST /cart mutation
Clear-Site-Data
Navigate /checkout
Select a scenario and click Run.
// Scenario: cart mutation arrives before user navigates
//
// 1. Speculation rules prerender /checkout
// <script type="speculation-rules">
// {"prerender": [{"source": "list", "urls": ["/checkout"]}]}
// </script>
//
// 2. User adds item to cart — response cancels the prerender:
// POST /cart/add
// <- Clear-Site-Data: "prerenderCache"
//
// 3. User clicks "Checkout" — prerender is GONE:
// → fresh navigation, correct cart total
// → no stale checkout page served from cache
// If the user clicks BEFORE the mutation response:
// → prerender activates with stale cart total (race condition!)
// → merchant must also return Clear-Site-Data from /checkout itself