YSlow and Compress Components with GZip
With the Firebug add-on YSlow, one of the components that gets rated is something called Compress components with gzip. When you run YSlow to optimize your website or blog, you may be getting dinged on that component. Here is how to improve your site’s speed a bit – with two huge caveats:
- You web server must be running Apache 1.3
- Your Apache 1.3 must use mod_gzip
If those two items are true, then to set up gzip compression, paste the following into your .htaccess file**.
mod_gzip_handle_methods GET POST
mod_gzip_item_include file \.html$
mod_gzip_item_include file \.php$
mod_gzip_item_include file \.pl$
mod_gzip_item_include file \.rb$
mod_gzip_item_include file \.py$
mod_gzip_item_include file \.cgi$
mod_gzip_item_include file \.css$
mod_gzip_item_include file \.js$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^httpd/unix-directory$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include handler ^server-status$
mod_gzip_item_include handler ^server-info$
mod_gzip_item_include handler ^application/x-httpd-php
mod_gzip_item_exclude mime ^image/.*
If all goes well, you should now get an A for Compress components with gzip*.
**If you do not have an .htaccess file in you file system, you can create one. Simply create a file called “.htaccess” in your web root. Open the file in your favorite editor and paste in the code above, save and close. Sometimes, the .htaccess file is hidden from view. If so, you may need to turn on a toggle for “Show Invisible Files” or something similar in you FTP application or Web File Browser.