Y慢& Google Page Speed 关于 .htaccess 冲突的建议

发布于 2024-09-28 05:30:31 字数 871 浏览 1 评论 0原文

预先感谢您的帮助。

我一直在尝试 YSlow 和 Google 页面速度,两者都提供了非常有用的建议,并且似乎没有一个比另一个更有优势,但当涉及到实体标签时,它们似乎在某种程度上存在分歧或冲突。以下代码满足 YSlows“配置实体标记 (ETags)”指针,

Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header unset Last-Modified
Header set Expires "Fri, 21 Dec 2050 00:00:00 GMT"
Header set Cache-Control "public, no-transform"
</FilesMatch>

但是使用此代码后,Google Page Speed 会提供以下建议“指定缓存验证器”。另一位成员Aularon建议使用此代码来满足Google的要求

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 year"
</IfModule>

两者分开工作,但是这两个解决方案都不能满足两个验证者的要求,所以我的问题是。

  1. 我应该关心吗?
  2. 对于两个验证器来说有一个好的解决方案吗?
  3. 这两种解决方案真的会产生重大影响吗?

Thanks in advance for your help.

I've been experimenting with YSlow and Google page speed, both provide very helpful advice and neither seems to have an advantage over the other but when it comes to Entity tags they seem to disagree or conflict in some way. The following code satisfies YSlows 'Configure entity tags (ETags)' pointer

Header unset ETag
FileETag None
<FilesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header unset Last-Modified
Header set Expires "Fri, 21 Dec 2050 00:00:00 GMT"
Header set Cache-Control "public, no-transform"
</FilesMatch>

However with this code in place Google Page Speed provides the following advice 'specify a cache validator'. Another member Aularon suggests using this code to satisfy Google's requirement

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 1 year"
</IfModule>

Both work separately, but neither solution satisfies both validators, so my questions are.

  1. Should I care?
  2. Is there a good solution for both validators?
  3. Does either solution really have a major impact?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你对谁都笑 2024-10-05 05:30:31
  1. 是的,
  2. 正如Yi Jiang指出的那样,这些不是验证者。这些工具可帮助您评估页面的性能。您需要考虑他们的建议。但是,设置诸如“过期标头”之类的内容并不一定意味着用户代理会遵守这一点。就我个人而言,我看到 Firebug 中的 YSlow 插件没有列出某些资源,因为它们已设置了标头,尽管我已经设置了。重点是考虑这两种工具的输出,但我不会因为试图让这两种工具都满意而责备自己。
  3. 当然。您的第一个过期代码集的所有图形资源在接下来的 40 年内不会过期。这将对回访者的下载时间产生巨大影响。以及站点维护 - 即确保在站点更改时使缓存失效。您的第二条规则将所有内容缓存一年。这将对您的网站产生非常严重的影响 - 例如缓存您的所有资源,包括 html 页面!
  1. Yes
  2. As Yi Jiang pointed out, these are not validators. These are tools to help you evaluate the performance of your page. You need to consider their recommendations. However, setting something like the Expires Header doesn't necessarily mean the user agent will honor that. Personally, I've seen the YSlow add-on in Firebug not list certain resources as having their Header set even though I have. The point is consider output from both tools, but I wouldn't beat yourself up over trying to make both happy.
  3. Of course. Your first expires code set's all graphical resources to not expire for the next 40 years. That would have a huge impact on download times for return visitors. As well as site maintenance - i.e. ensuring to invalidate the cache as the site changes. Your second rule caches everything for a year. That would have very serious impact on your site - e.g. caching all your resources, including html pages!
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文