How can I have a bad Time to First Byte on Core Web Vitals, but a good TTFB on all Pagespeed tests?

huangapple go评论110阅读模式
英文:

How can I have a bad Time to First Byte on Core Web Vitals, but a good TTFB on all Pagespeed tests?

问题

I'm here to provide a Chinese translation of the content you provided. Here it is:

问题
我正在尝试找到关于Google的PageSpeed Insights(Lighthouse)上的以下不一致性的解释:

顶部的“核心Web性能评估”部分始终列出相当糟糕的TTFB。 例如,对于一个没有任何其他依赖项的随机静态HTML文档(700毫秒),它看起来像这样:

How can I have a bad Time to First Byte on Core Web Vitals, but a good TTFB on all Pagespeed tests?

然而,在同一结果页面上,Google还列出了“初始服务器响应时间很短”测试(在“通过的审核”部分)要好得多(40毫秒):
How can I have a bad Time to First Byte on Core Web Vitals, but a good TTFB on all Pagespeed tests?

在这个例子中,这是1750%的差异!

这怎么可能?


额外思考
这两个指标应该描述的是相同的,不是吗?

我理解核心Web性能评估应该是“您的实际用户正在经历的情况”,即在真实用户的先前网站调用中收集的分析数据。相比之下,其他值描述的是在那一刻执行的单个测试快照。

然而,这并不像“我只是幸运地拍了一次,但通常需要更长时间”那么简单。我从不同地点、不同时间、使用不同设备等进行了大量测试,所有手动测试都非常快速。只有核心Web性能评估要差得多,我找不到解释。

“用户使用较慢的互联网连接”也不是一个解释,对吧?我可以理解在页面的最后一部分之前的差异,但是第一个字节如何以如此激烈的方式受到影响呢?

英文:

Question

I'm trying to find an explanation for the following inconsistency on Google's PageSpeed Insights (Lighthouse):

The "Core Web Vitals Assessment" section at the top always lists a quite bad TTFB. For instance, it looks like this for a random static HTML document without any additional dependencies (700ms):

How can I have a bad Time to First Byte on Core Web Vitals, but a good TTFB on all Pagespeed tests?

However, on the same result page Google also lists the "Initial server response time was short" test (in the "passed audits" section) much much better (40ms):
How can I have a bad Time to First Byte on Core Web Vitals, but a good TTFB on all Pagespeed tests?

In this example, that's a difference of 1750%!

How is this possible?


Additional Thoughts

Both metrics are supposed to describe the same, aren't they?

I do understand that the Core Web Vitals is supposed to be "what your real users are experiencing", i.e. analytical data collected on previous web site calls of real users. In contrast, the other value describes a single test snapshot as performed in that moment.

It's not as easy as "I just had a lucky shot, but usually it takes longer." though. I performed lots of tests from different locations, at different times, using various devices etc. and all manual tests are pretty fast. Only the Core Web Vitals are much worse and I can't find an explanation for it.

"Users having a slower Internet connection" isn't an explanation either, right? I could understand the difference until the last part of the page is there, but how can the very first byte be affected by this in such a drastic way?

答案1

得分: 4

Both metrics are supposed to describe the same, aren't they?
两个指标应该描述相同的内容,不是吗?

No they are not the same. Lighthouse deliberately avoids using the term TTFB and uses Server time because they are different.
不,它们不相同。Lighthouse故意避免使用术语TTFB,而使用服务器时间,因为它们是不同的。

Lighthouse typically normalizes URLs. So if you enter https://web.dev/ttfb and that redirects to https://web.dev/ttfb/ by adding a trailing slash, then Lighthouse will run with the trailing slash. PageSpeed Insights will warn you of this, but your users may be using the pre-redirect URL so won't get this normalization:
Lighthouse通常会标准化URL。因此,如果您输入https://web.dev/ttfb,并且它通过添加尾部斜杠重定向到https://web.dev/ttfb/,那么Lighthouse将以带有尾部斜杠的方式运行。PageSpeed Insights会提醒您,但您的用户可能正在使用重定向前的URL,因此不会获得此标准化:

Additionally many of your users will not come directly to the correct URL either. They may be going through link shorteners (e.g. t.co for Twitter), or via an Ad that runs through several redirects before actually requesting the page - and yes redirects count towards TTFB and so also FCP and LCP.
另外,您的许多用户也不会直接访问正确的URL。他们可能通过链接缩短服务(例如Twitter的t.co)或通过广告进行多次重定向后才真正请求页面 - 是的,重定向会计入TTFB以及FCP和LCP。

"Users having a slower Internet connection" isn't an explanation either, right? I could understand the difference until the last part of the page is there, but how can the very first byte be affected by this in such a drastic way?
"用户拥有较慢的互联网连接"也不是一个解释,对吗?我可以理解差异,直到页面的最后部分出现,但第一个字节如何受到如此剧烈的影响呢?

This absolutely can be a reason, even if there are no redirects discussed above. PageSpeed Insights runs from a server and is permanently connected to the internet, whereas your users may not be. It's true that Lighthouse attempts to simulate a slowed down connection, but that is an estimate. Real users may be connecting from far away countries, or patching mobile networks out in the countryside, where there is a significant delay from clicking on a link or typing a URL, before the page is even requested.
这绝对_可以_是一个原因,即使上面没有讨论重定向。PageSpeed Insights是从服务器运行的,并且始终连接到互联网,而您的用户可能没有连接到互联网。Lighthouse确实试图模拟减慢的连接,但那只是一个估计。真实用户可能连接来自遥远的国家,或者在乡村地区连接移动网络,在点击链接或输入URL之前,页面甚至还未请求之前就会出现显著延迟。

Repeatedly running a PSI test may give different results than to real users depending on how your infrastructure is set up. Is it cached at a CDN edge node so the PSI run is repeatedly hitting that cached version and very quick, whereas a user connecting to another CDN edge node may not have that cached and so have to wait until the CDN goes all the way back to the origin? Is the server always running or is there a booting up time if something has not been requested in some time, so again infrequently requested resources (whether for that CDN edge node, or just a lesser trafficked page) may have different server response times for repeat tests than for other users.
反复运行PSI测试可能会产生不同的结果,这取决于您的基础架构设置方式。它是否缓存在CDN边缘节点上,以便PSI运行重复命中缓存版本,并且非常快速,而连接到另一个CDN边缘节点的用户可能没有缓存,因此必须等待CDN返回到源站?服务器是否始终运行,或者如果有一段时间没有请求,是否存在启动时间,因此再次请求的资源(无论是针对CDN边缘节点还是只是流量较小的页面)可能会与其他用户的重复测试有不同的服务器响应时间。

Finally, your screenshot shows it is not the page TTFB that is shown, but the origin TTFB as no page level data was available:
最后,您的截图显示的不是页面TTFB,而是源TTFB,因为没有可用的页面级数据。

英文:

> Both metrics are supposed to describe the same, aren't they?

No they are not the same. Lighthouse deliberately avoids using the term TTFB and uses Server time because they are different.

Lighthouse typically normalises URLs. So if you enter https://web.dev/ttfb and that redirects to https://web.dev/ttfb/ by adding a trailing slash, then Lighthouse will run with the trailing slash. PageSpeed Insights will warn you of this, but your users may be using the pre-redirect URL so won't get this normalisation:

How can I have a bad Time to First Byte on Core Web Vitals, but a good TTFB on all Pagespeed tests?

Additionally many of your users will not come directly to the correct URL either. They may be going through link shorteners (e.g. t.co for Twitter), or via an Ad that runs through several redirects before actually requesting the page - and yes redirects count towards TTFB and so also FCP and LCP

Event without these, Lighthouse does not currently show TTFB, but only shows the server response time (it strips out any DNS and Redirect time to just show this portion).

> "Users having a slower Internet connection" isn't an explanation either, right? I could understand the difference until the last part of the page is there, but how can the very first byte be affected by this in such a drastic way?

This absolutely can be a reason, even if there are no redirects discussed above. PageSpeed Insights runs from a server and is permanently connected to the internet, whereas your users may not be. It's true that Lighthouse attempts to simulate a slowed down connection, but that is an estimate. Real users may be connecting from far away countries, or patching mobile networks out in the countryside, where there is a significant delay from clicking on a link or typing a URL, before the page is even requested.

Repeatedly running a PSI test may give different results than to real users depending on how your infrastructure is set up. Is it cached at a CDN edge node so the PSI run is repeatedly hitting that cached version and very quick, whereas a user connecting to another CDN edge node may not have that cached and so have to wait until the CDN goes all the way back to the origin? Is the server always running or is there a booting up time if something has not been requested in some time, so again infrequently requested resources (whether for that CDN edge node, or just a lesser trafficked page) may have different server response times for repeat tests than for other users.

Finally, your screenshot shows it is not the page TTFB that is shown, but the origin TTFB as no page level data was available:

How can I have a bad Time to First Byte on Core Web Vitals, but a good TTFB on all Pagespeed tests?

Perhaps you have some pages that take longer to generate server-side as they do a lot of processing (for reasons given above, or other reasons) but you're testing a quick page in this test.

huangapple
  • 本文由 发表于 2023年5月23日 00:55:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76308397.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定