如何测试dns-prefetch和preconnect的效果 [英] How do you test the effects of dns-prefetch and preconnect

查看:767
本文介绍了如何测试dns-prefetch和preconnect的效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试< link rel =dns-prefetch> < link rel =preconnect> ; 标签,我正在尝试查看它们是否对我的网站有所帮助。我找不到任何有关如何使用浏览器开发工具,扩展程序或其他软件验证这些提示是否有效的在线资源。看起来您只是根据某些标准评估它们是否对您有用,然后将它们放入并希望最好。

I'm trying out the <link rel="dns-prefetch"> and <link rel="preconnect"> tags and I'm trying to see whether they help for my site. I can't find any online resources about how verify if these hints are working using browser dev tools, extensions, or other software. It seems like you just evaluate whether they may be useful to you based on some criteria and then drop them in and hope for the best.

在我的情况下,我有一个单页应用,在浏览器中呈现< body> 的全部内容,因此浏览器无法真正扫描初始HTML以预测要解析的域,以便它好像这对我有用。

In my case, I have a single page app that renders the entire contents of the <body> in the browser, so the browser can't really scan the initial HTML to lookahead for domains to resolve so it seemed like this might be useful for me.

推荐答案

通过webpagetest.org运行你的页面。对您在dns-prefetch或preconnect标记中指定的域的请求应该更快开始,因为初始连接已经建立。

Run your page through webpagetest.org. Requests to the domains you specified in your dns-prefetch or preconnect tags should begin sooner because the initial connection will have been established.

这将在瀑布图中显示,对于那些请求 - 在条形图的左侧,DNS,连接和SSL(如果适用)段将从响应中分离出来在瀑布中向左移动,以反映它们早先发生的事实。

This will show in the waterfall graph, for those requests - at the left of the bar the DNS, connect and SSL (if applicable) segments will detach from the response and move to the left in the waterfall, to reflect the fact that they occurred earlier.

这篇关于如何测试dns-prefetch和preconnect的效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆