Keita Suzuki | 44b2afc | 2024-11-07 12:46:35 | [diff] [blame] | 1 | # Timing information for ServiceWorker Static Routing API |
| 2 | |
| 3 | - Contact: chrome-loading@google.com |
| 4 | |
| 5 | This document describes the status of the current implementation of the |
| 6 | [**Timing Info for ServiceWorker Static Routing API**](https://github.com/WICG/service-worker-static-routing-api/blob/main/resource-timing-api.md) |
| 7 | in Chrome, and how to enable it. |
| 8 | |
| 9 | Note that this feature is not available by default. |
| 10 | Chrome plans to do an origin trial starting from M131 to evaluate its |
| 11 | effectiveness and to allow site authors to give feedback. |
| 12 | |
| 13 | ## What’s supported |
| 14 | |
| 15 | The API is implemented according to the |
| 16 | [explainer](https://github.com/WICG/service-worker-static-routing-api/blob/main/resource-timing-api.md). |
| 17 | |
| 18 | Following new fields are added to the resourceTimingAPI: |
| 19 | - workerMatchedRouterSource |
| 20 | - workerActualRouterSource |
| 21 | - workerCacheLookupStart |
| 22 | |
| 23 | In addition, a new value `cache-storage` is added to the `deliveryType` field. |
| 24 | Please refer to the explainer for details about each field. |
| 25 | |
| 26 | ## Activation |
| 27 | |
| 28 | The API can be enabled by participating in the [Origin Trial](https://developer.chrome.com/blog/origin-trials/). |
| 29 | |
| 30 | The feature is named `ServiceWorkerStaticRouterTimingInfo`. |
| 31 | Registration for the trial is [here](https://developer.chrome.com/origintrials/#/view_trial/1689412810217357313). |
| 32 | See [feature status](https://chromestatus.com/feature/6309742380318720) to find out |
| 33 | if the origin trial is currently running. |
| 34 | |
| 35 | The [origin trial tutorial](https://developer.chrome.com/docs/web-platform/origin-trials/#take-part-in-an-origin-trial) describes how to participate. |
| 36 | |
| 37 | |
| 38 | ## Verifying the API is working |
| 39 | |
| 40 | In devtools, run the following piece of javascript after navigating to a page |
| 41 | which uses ServiceWorker static routing API. |
| 42 | |
| 43 | ```js |
| 44 | performance.getEntriesByType('navigation')[0].matchedSourceType; |
| 45 | ``` |
| 46 | |
| 47 | If it gives you a value, it succeeds. |
| 48 | If it gives `undefined` then the feature is not enabled. |
| 49 | |
| 50 | ## Related Links |
| 51 | |
| 52 | - [Timing Info for ServiceWorker Static Routing API Explinaer on GitHub](https://github.com/WICG/service-worker-static-routing-api/blob/main/resource-timing-api.md) |
| 53 | - [Chrome Status](https://chromestatus.com/feature/6309742380318720) |