gzip 工作但 YSlow 表明它不工作
我已经习惯了 Firebug 和 YSlow,尤其是。我正在研究的事情之一是 gzip 压缩。 YSlow 仍然给我的网站一个“F”,并表明我的 CSS 和 JavaScript 文件没有被压缩。
但是,如果我对我的网站运行外部 gzip 测试(例如 http://www.gidnetwork.com/tools/gzip-test.php ),它会告诉我 gzip 正在工作并给我我的积蓄,虽然我认为这可能只是 HTML。
这是我的 .htaccess 文件的相关部分:
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.css$
mod_gzip_item_include file \.(html?|txt|js|php|pl|jpg|png|gif)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
Why does YSlow notgree with the external gzip test?
I'm getting used to Firebug and YSlow in particular. One of the things I'm looking at is the gzip compression. YSlow still gives my site an "F" and indicates that my CSS and JavaScript files are not being compressed.
However, if I run an external gzip test against my site (such as http://www.gidnetwork.com/tools/gzip-test.php
) it tells me that gzip is working and gives me my savings, although I think this may just be the HTML.
This is the relevant section of my .htaccess
file:
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.css$
mod_gzip_item_include file \.(html?|txt|js|php|pl|jpg|png|gif)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
Why does YSlow not agree with the external gzip test?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
mod_gzip
是 Apache 1.x 中已过时的部分,已在 Apache 2 中被mod_deflate
取代。此
mod_deflate
配置使 YSlow 在这里感到高兴:有两行
AddOutputFilterByType
行的唯一原因是避免水平滚动。mod_gzip
is an obsolete part of Apache 1.x, having been replaced bymod_deflate
in Apache 2.This
mod_deflate
configuration makes YSlow happy here:The only reason there are two
AddOutputFilterByType
lines is to avoid horizontal scrolling.不在代理后面进行测量?我的工作代理搞砸了我的 yslow 结果......!
Not measuring behind a proxy? My work proxy screws with my yslow results...!
只需将下一个代码添加到您的 .htaccess
似乎它会使 GTmetrix & Yslow happy
添加
如果您使用的是 PHP,请不要忘记在头文件的开头
Just add the next code to your .htaccess
Seems it makes both GTmetrix & Yslow happy
Don't forget to add
at the beginning of your header file if your are using PHP