Hiroki Nakagawa | 0c9ee9f9 | 2020-10-16 02:46:56 | [diff] [blame] | 1 | # 103 Early Hints |
| 2 | |
Kenichi Ishibashi | 392a760 | 2023-02-16 03:09:45 | [diff] [blame] | 3 | Contact: net-dev@chromium.org |
Hiroki Nakagawa | 0c9ee9f9 | 2020-10-16 02:46:56 | [diff] [blame] | 4 | |
Kenichi Ishibashi | 392a760 | 2023-02-16 03:09:45 | [diff] [blame] | 5 | As of version 103, Chrome supports |
Kenichi Ishibashi | 7e394ecd | 2021-08-24 07:28:24 | [diff] [blame] | 6 | [Early Hints](https://datatracker.ietf.org/doc/html/rfc8297). |
Kenichi Ishibashi | 6d43eb85 | 2022-04-20 02:28:54 | [diff] [blame] | 7 | Early Hints enable browsers to preload subresources or preconnect to servers |
| 8 | before the main response is served. See the |
| 9 | [explainer](https://github.com/bashi/early-hints-explainer/blob/main/explainer.md) |
| 10 | how it works. |
Hiroki Nakagawa | 0c9ee9f9 | 2020-10-16 02:46:56 | [diff] [blame] | 11 | |
Kenichi Ishibashi | 7e394ecd | 2021-08-24 07:28:24 | [diff] [blame] | 12 | ## What’s supported |
Hiroki Nakagawa | 0c9ee9f9 | 2020-10-16 02:46:56 | [diff] [blame] | 13 | |
Kenichi Ishibashi | cdbd1ec9e | 2021-09-03 00:24:47 | [diff] [blame] | 14 | Chrome supports [preload](https://w3c.github.io/preload/) and |
| 15 | [preconnect](https://w3c.github.io/resource-hints/#dfn-preconnect) in |
Kenichi Ishibashi | 6d43eb85 | 2022-04-20 02:28:54 | [diff] [blame] | 16 | Early Hints for top-level frame navigation. |
Hiroki Nakagawa | 0c9ee9f9 | 2020-10-16 02:46:56 | [diff] [blame] | 17 | |
Kenichi Ishibashi | 7e394ecd | 2021-08-24 07:28:24 | [diff] [blame] | 18 | ## What’s not supported |
Hiroki Nakagawa | 0c9ee9f9 | 2020-10-16 02:46:56 | [diff] [blame] | 19 | |
Kenichi Ishibashi | 6d43eb85 | 2022-04-20 02:28:54 | [diff] [blame] | 20 | To reduce security and privacy implications, the HTML and Fetch living standards |
| 21 | have some restrictions on when Early Hints can be handled. Chrome ignores Early |
| 22 | Hints sent in the following situations to comply these specifications. |
Hiroki Nakagawa | 0c9ee9f9 | 2020-10-16 02:46:56 | [diff] [blame] | 23 | |
Kenichi Ishibashi | 7e394ecd | 2021-08-24 07:28:24 | [diff] [blame] | 24 | * Early Hints sent on subresource requests |
| 25 | * Early Hints sent on iframe navigation |
| 26 | * Early Hints sent on HTTP/1.1 or earlier |
Hiroki Nakagawa | 0c9ee9f9 | 2020-10-16 02:46:56 | [diff] [blame] | 27 | |
Kenichi Ishibashi | 6d43eb85 | 2022-04-20 02:28:54 | [diff] [blame] | 28 | Chrome ignores the second and following Early Hints responses. Chrome only |
| 29 | handles the first Early Hints response so that Chrome doesn't apply inconsistent |
| 30 | security policies (e.g. Content-Security-Policy). |
| 31 | |
Kenichi Ishibashi | cdbd1ec9e | 2021-09-03 00:24:47 | [diff] [blame] | 32 | Chrome doesn’t handle |
| 33 | [dns-prefetch](https://w3c.github.io/resource-hints/#dfn-dns-prefetch) and |
| 34 | [prefetch](https://w3c.github.io/resource-hints/#dfn-prefetch) in Early Hints |
| 35 | yet. We consider supporting them in the future. |
Hiroki Nakagawa | 0c9ee9f9 | 2020-10-16 02:46:56 | [diff] [blame] | 36 | |
Kenichi Ishibashi | 392a760 | 2023-02-16 03:09:45 | [diff] [blame] | 37 | ## Checking Early Hints preload is working |
Kenichi Ishibashi | 7e394ecd | 2021-08-24 07:28:24 | [diff] [blame] | 38 | |
| 39 | If a resource is preloaded by Early Hints, the corresponding |
| 40 | [PerformanceResourceTiming](https://w3c.github.io/resource-timing/#sec-performanceresourcetiming) |
| 41 | object reports `initiatorType` is "early-hints". |
| 42 | ``` |
Eric Lawrence [MSFT] | 694be82 | 2021-09-03 23:34:22 | [diff] [blame] | 43 | performance.getEntriesByName('https://a.test/style.css')[0].initiatorType |
Kenichi Ishibashi | 7e394ecd | 2021-08-24 07:28:24 | [diff] [blame] | 44 | // => 'early-hints' |
| 45 | ``` |
| 46 | |
Kenichi Ishibashi | 539af45 | 2023-05-19 07:09:24 | [diff] [blame] | 47 | ### Reliability of `initiatorType` |
Kenichi Ishibashi | 392a760 | 2023-02-16 03:09:45 | [diff] [blame] | 48 | |
Kenichi Ishibashi | 539af45 | 2023-05-19 07:09:24 | [diff] [blame] | 49 | Due to an implementation limitation, `initiatorType` may not always set to |
| 50 | "early-hints". See |
| 51 | [the proposal](https://docs.google.com/document/d/1V7xX2cRNxcsuIrtZk4srdZuqXynnYlPG9fFDnELXC_Y/edit?usp=sharing) |
| 52 | for more details. |