← Chrome 151 reference

v151 · performance · service-worker · resource-timing

Resource Timing: Add spec-compliant Service Worker Router timing fields

Chrome 151 adds two new attributes to PerformanceResourceTiming (and PerformanceNavigationTiming): workerMatchedRouterSource and workerFinalRouterSource, which identify which Service Worker Static Router rule was matched and the final source used to fulfil the request.

at a glance

Shipped inChrome 151 (Enabled by default)
StatusEnabled by default
Standards position (Firefox)No signal
Standards position (Safari)No signal
Spec PRw3c/resource-timing PR #415
ChromeStatus5172259800088576 — Resource Timing: Add spec-compliant Service Worker Router timing fields (API record)
Source: chromestatus.com/feature/5172259800088576

background: Service Worker Static Routing

The Service Worker Static Routing API (shipped in Chrome 123) allows service workers to declare routing rules that short-circuit the fetch event, directing requests to the network, cache, or the fetch handler without waking the service worker. The RouterSource values identify where the final response came from: "network", "cache", "fetch-event", or "race-network-and-fetch-handler".

Source: SW static routing resource timing explainer

Syntax

Web IDL definition from the W3C Resource Timing specification and PR #415 extending PerformanceResourceTiming (which PerformanceNavigationTiming inherits):

partial interface PerformanceResourceTiming {
  readonly attribute DOMString workerMatchedRouterSource;
  readonly attribute DOMString workerFinalRouterSource;
};
Source: w3c/resource-timing PR #415; W3C Resource Timing

shape of the API

AttributeInterfaceDescription
workerMatchedRouterSourcePerformanceResourceTiming, PerformanceNavigationTimingThe RouterSource of the Static Router rule that first matched this request (or "" if no rule matched)
workerFinalRouterSourcePerformanceResourceTiming, PerformanceNavigationTimingThe RouterSource that ultimately served the response (may differ from matched if a race resolved differently)

Deprecation note: The existing non-compliant fields workerMatchedSourceType and workerFinalSourceType will be deprecated in a separate future intent once usage data is collected.

Source: chromestatus feature summary

Inputs and parameters

Both workerMatchedRouterSource and workerFinalRouterSource are read-only attributes on PerformanceResourceTiming instances. They take no input arguments and do not define property setters; attempting to write to them in strict mode throws a TypeError.

Source: w3c/resource-timing PR #415 IDL

Outputs and return values

Each attribute returns a DOMString. If a service worker static routing rule applied to the request, the values correspond to the ServiceWorker specification router sources: "network", "cache", "fetch-event", or "race-network-and-fetch-handler". If no static router rule matched the request, an empty string ("") is returned.

Source: WICG resource-timing-api explainer

Errors and exceptions

Reading these attributes never throws an exception during normal execution. If invoked on an object that does not implement the PerformanceResourceTiming interface, the Web IDL getter algorithm throws a standard TypeError: Illegal invocation.

Source: W3C Resource Timing §PerformanceResourceTiming

Execution context and exposure

These attributes are exposed on PerformanceResourceTiming and PerformanceNavigationTiming in both Window and DedicatedWorker contexts where the Resource Timing API is accessible. They are available in both secure and non-secure origins.

Source: MDN PerformanceResourceTiming

Lifecycle and state transitions

The values of workerMatchedRouterSource and workerFinalRouterSource are populated by the browser networking layer when a fetch request matches the service worker static router. They remain immutable on the resulting PerformanceResourceTiming entry once the resource load completes and the entry is recorded into the performance timeline.

Source: WICG resource-timing-api explainer

Examples

// After a page load, inspect resource timing entries for SW router info
const entries = performance.getEntriesByType('resource');
for (const entry of entries) {
  if (entry.workerMatchedRouterSource) {
    console.log(
      entry.name,
      '→ matched:', entry.workerMatchedRouterSource,
      '→ final:',   entry.workerFinalRouterSource
    );
    // Example output:
    // "/api/data.json" → matched: "race-network-and-fetch-handler" → final: "network"
  }
}

// Navigation timing also includes these fields (Chrome 151+)
const [nav] = performance.getEntriesByType('navigation');
console.log('Nav router source:', nav.workerFinalRouterSource);
Source: chromestatus feature summary

Browser compatibility

BrowserSupportNotes
Chrome 151+Enabled by defaultSpec-compliant names replacing legacy workerMatchedSourceType
FirefoxNo signalStatic routing API under discussion
SafariNo signalStatic routing API under discussion
Source: chromestatus.com/feature/5172259800088576

Security and privacy considerations

These timing attributes report the routing source chosen by the origin's own registered service worker. For cross-origin subresources, detailed timing attributes on PerformanceResourceTiming are constrained by the Timing-Allow-Origin header, preserving cross-origin privacy and preventing cross-origin cache probing.

Source: W3C Resource Timing §security

see also