2

我们正在使用 Google Cloud Platform 来托管一个 WordPress 网站:

Google Load Balancer with CDN -> Instance Group with single VM -> Nginx + WordPress

从第 1 步(只有带有 WordPress 的虚拟机,没有缓存)到最后一步(使用负载均衡器和 CDN 的整个设置),当我从浏览器和 GTmetrix 进行本地测试时,我可以逐渐看到改进。但 PageSpeed Insights 的改进总是很少。

现在我们为在 GTmetrix 中获得令人印象深刻的98/97 分感到自豪(哇!),但 PSI 仍然显示我们相当平均,特别是在移动设备上(范围为 45-55)。

问题:我们关心谷歌中的页面排名,所以我们也想让 PSI 高兴。另外......我们的客户不会明白我们确实做出了改进,而 PSI 仍然显示该分数。

我正在挖掘并发现有关 PSI 的一些奇怪的事情:

  • 当我们cache-control在 nginx 中进行调整时,它被本地浏览器和 GTmetrix 正确检测到,但是在 PSI 中使用有效缓存策略服务静态资产部分显示了几天的旧值。
  • 主页有一个以 3 种格式(mp4、webm、ogv)托管的背景视频。客户端应该只请求其中一个(我的浏览器和 GTmetrix 会),但 PSI 实际上请求其中的 3 个。我可以在避免巨大的网络负载部分看到它们。
  • 当客户端请求我们的主页时,只有GET /请求到达我们的后端服务器(这是预期的行为),其余的静态资产由 CDN 提供。但是当从 PSI 进行测试时,所有请求都会到达我们的后端服务器。我可以在 nginx 访问日志中看到它们。

所以...这 3 点让我们在 PSI 中获得更差的分数(点 1 在我们改变后的几天后突然自行修复cache-control),但据我所知,它们都不应该发生。还有什么我想念的吗?

提前感谢那些可以对此有所了解的人。

4

1 回答 1

1

但 PSI 仍然显示我们相当平均,特别是在移动设备上(范围从 45 到 55)。

PSI defaults to show you a mobile score on a simulated throttled connection. If you look at the desktop tab this is comparable to GT Metrix (which uses the same engine 'Lighthouse' under the hood without throttling so will give similar results on Desktop).

Sorry to tell you but the site is only average on mobile speed, test it by going to Performance tab in developer tools and enabling 'Network:Fast 3G' and 'CPU: 4x Slowdown' in the throttling options.

Plus the site seems really JavaScript computation heavy for some reason, PSI simulates a slower CPU so this is another factor. One script is taking nearly 1 second to evaluate.

Serve static assets with an efficient cache policy in PSI showed the old values for a few days.

This is far more likely to be a config issue than a PSI issue. PSI always runs from an empty cache. Perhaps the roll out across all CDNs is slow for some reason and PSI was requesting from a different CDN to you?

Videos - but PSI actually requests the 3 of them. I can see them in Avoid enormous network payloads section.

Do not confuse what you see here with what Google has used to actually run your test. This is calculated separately from all assets that it can download not based on the run data that is calculated by loading the page in a headless browser.

Also these assets are the same for desktop and mobile so it could be for some reason it is using one asset for the mobile test and one for the desktop test.

Either way it does indeed look like a bug but it will not affect your score as that is calculated in other ways.

all requests reach our backend server

Then this points to a similar problem as with point 1 - are you sure your CDN has fully deployed? Either that or you have some rule set up for a certain user agent / robots rule set up that bypasses your CDN. Most likely a robots rule needs updating.

What can you do?

  1. double check your config, deployment etc. Ensure it has propagated to all CDN sites and that all of the DNS routing is working as expected.

  2. Check that you don't have rules set for robots, I notice the site is 'noindex' so perhaps you do have something set up while you are testing things that is interfering.

  3. Run an 'Audit' from Developer Tools in Google Chrome -> this uses exactly the same engine that PSI uses. This may give you better results as it uses your actual browser rather than a headless browser. Although for me this stops the videos loading at all so something strange is happening with that.

于 2020-03-20T15:14:32.477 回答