v138 ยท service worker

ServiceWorker support for Speculation Rules Prefetch

This feature enables ServiceWorker-controlled prefetches, that is a speculation rules prefetch to URLs controlled by a Service Worker. Previously, the prefetch is cancelled upon detecting a controlling Service Worker, thus subsequent navigation to the prfetch target is served by the non-prefetch path. This feature will enable the prefetch request to go throu

concepts

  1. SW Spec Prefetch

    Service Workers now see speculation-rules prefetch requests in their fetch event. Lets SW-controlled sites do their own prefetch logic on the back of speculation rules.

  2. CDN-rewrite pipeline

    Three-node pipeline: speculation rule → SW fetch handler → outbound request. Inject auth, route to a regional CDN, skip server-side analytics — same logic SW already does for real navigations.

  3. Sec-Purpose inspector

    Live tool that installs a SW, intercepts both speculative prefetches and real navigations, and posts the full request headers back to the page โ€” classified by Sec-Purpose.

  4. Offline-capable spec prefetch

    A Service Worker intercepts speculation-rules prefetch requests, caches them via the Cache API, then serves them while "offline". Three panels walk through: prefetch+cache, go offline, navigate from cache. Shows Sec-Purpose: prefetch headers and cache state at each step.

why it shipped

Speculation rules prefetch is a popular feature, with ~11% of page loads initiating such a prefetch. Service workers are an even more popular feature, with ~25% of page loads controlled by a service worker.

references