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 in | Chrome 151 (Enabled by default) |
|---|---|
| Status | Enabled by default |
| Standards position (Firefox) | No signal |
| Standards position (Safari) | No signal |
| Spec PR | w3c/resource-timing PR #415 |
| ChromeStatus | 5172259800088576 — Resource Timing: Add spec-compliant Service Worker Router timing fields (API record) |
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".
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
| Attribute | Interface | Description |
|---|---|---|
workerMatchedRouterSource | PerformanceResourceTiming, PerformanceNavigationTiming | The RouterSource of the Static Router rule that first matched this request (or "" if no rule matched) |
workerFinalRouterSource | PerformanceResourceTiming, PerformanceNavigationTiming | The 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.
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.
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.
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.
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.
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.
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
| Browser | Support | Notes |
|---|---|---|
| Chrome 151+ | Enabled by default | Spec-compliant names replacing legacy workerMatchedSourceType |
| Firefox | No signal | Static routing API under discussion |
| Safari | No signal | Static routing API under discussion |
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.
see also
- Chrome Platform Status — Resource Timing: SW Router timing fields
- ChromeStatus API record (5172259800088576)
- W3C Resource Timing Pull Request #415
- W3C Resource Timing specification
- WICG Service Worker Static Routing Resource Timing Explainer
- WICG Service Worker Static Routing API Repository
- W3C Service Workers specification
- MDN Web Docs — PerformanceResourceTiming
- MDN Web Docs — PerformanceNavigationTiming
- WPT Results — resource-timing