PageSpeed评估和优化

12

我使用谷歌页面速度洞察分析了我的页面速度,并得到了以下建议。有人可以帮助我如何实施它吗?

Leverage browser caching
Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network.
Leverage browser caching for the following cacheable resources:
http://www.googletagmanager.com/gtm.js?id=GTM-TVSKP6 (16.2 minutes)
1个回答

19

你不能(因为你无法控制Google服务器,所以无法代表其设置http头)。

此外,你也不需要这样做。Google已经为gtm脚本设置了缓存控制头:

Cache-Control: private,max-age=931

"Private"表示http响应仅适用于单个用户,并且不应以使许多用户可以访问的方式进行缓存(例如代理服务器)。Max age是文档过期之前的最长时间,必须从服务器重新获取该文档。无论如何,你可能不想去调整这些设置,因为通常情况下,你希望对标签容器所做的任何更改迅速传播给你的用户。

Google pagespeed只是一个指南而已。设置http头是一种过度优化的方法,这对某些高流量站点可能有意义,但大多数站点首先应该解决其他更简单的问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接