Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gzip working but YSlow indicates it's not

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?

like image 867
scm8jet Avatar asked Nov 05 '22 00:11

scm8jet


1 Answers

mod_gzip is an obsolete part of Apache 1.x, having been replaced by mod_deflate in Apache 2.

This mod_deflate configuration makes YSlow happy here:

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE text/css text/html text/plain text/xml
    DeflateCompressionLevel 9
</IfModule>

The only reason there are two AddOutputFilterByType lines is to avoid horizontal scrolling.

like image 121
Warren Young Avatar answered Nov 09 '22 08:11

Warren Young