HTTP 103早期提示:如何诊断它们是否被Cloudflare正确设置并被Chrome尊重?

falq053o  于 2022-12-06  发布在  Go
关注(0)|答案(3)|浏览(165)

对于我的cryptocurrency market data website

  • 我在Cloudlare上有enabled early hints
  • 我正在生成有关SvelteKit/Vite Web服务器钩子的早期提示
  • 我已验证HTTP回复中是否存在Link标头
Link: </fonts3.css>; rel="preconnect", </_app/assets/start-6f5e0715.css>; rel="preconnect", </_app/assets/pages/__layout.svelte-f31b19cc.css>; rel="preconnect", </_app/assets/pages/index.svelte-84a34be8.css>; rel="preconnect"
  • 我已启用Chrome命令行标志以尊重早期提示

现在,我如何验证

  • Cloudflare正在正确生成HTTP/1.1 103 Early Hints。我可以用curlwget显示此信息吗?
  • Chrome尊重早期的提示--这是在webr开发者工具的性能标签中显示的,还是在其他地方?
yhived7q

yhived7q1#

I have no luck to verify Chrome's response from Chrome's devtool. When I monitor the network traffic, Chrome devtool does not show 103 responses at all. However, I am able to verify the server 103 responses using curl. Here is a curl output sample:
$ curl -k -v —http2 https://evanella.org
...

  • Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
  • Using Stream ID: 1 (easy handle 0x7fa7a2009200)

GET / HTTP/2 Host: evanella.org User-Agent: curl/7.64.1 Accept: /
...

  • Connection state changed (MAX_CONCURRENT_STREAMS == 100)!

< HTTP/2 103
< link: https://evanella.org/ ; rel=preload;
< link: https://evanella.org/wp-content/themes/twentytwentytwo/assets/fonts/SourceSerif4Variable-Roman.ttf.woff2 ; rel=preload; as=font
< link: https://evanella.org/wp-content/themes/twentytwentytwo/assets/images/flight-path-on-transparent-d.png ; rel=preload; as=image
< link: https://evanella.org/wp-content/themes/twentytwentytwo/style.css?ver=1.1 ; rel=preload; as=style
< link: https://evanella.org/wp-includes/blocks/navigation/view.min.js?ver=3776ea67846b3bb10fe8f7cdd486b0ba ; rel=preload; as=script
...
< HTTP/2 200
< server: h2o/2.3.0-DEV@998a7fb7b
< content-type: text/html; charset=UTF-8
< link: https://evanella.org/wp-json/ ; rel="https://api.w.org/"
< vary: Accept-Encoding
BTW, I configured my own webserver to generate the 103 early hints responses.

7tofc5zh

7tofc5zh2#

此网站是一个在线工具,用于测试是否提供了早期提示:
https://code103.hotmann.de

uklbhaso

uklbhaso3#

在chrome中,您可以在控制台中输入以下内容:
performance.getEntriesByName('https://yourwebsite.com/image.jpg')[0].initiatorType,其将分别输出linkearly-hints(可能是更多的值等),在early-hints的情况下,其指示由103报头发起的特定资源下载。
在我的情况下,我在接收link时卡住了,而early-hints是预期的。如果我在调试过程中了解到更多信息,我将更新此响应。

相关问题