Translate

29 June 2009

Blogging Tips : Gzip Compression Rocks

Today I received an email from Luciano Passuello, a long time DBT reader. He basically told me that he was running some bechmarks on website load performance, and that Daily Blog Tips was performing very good according to his tests. The only point where it could improve was on the Gzip compression.

I wanted to test with Gzip compression for a long time, so today I got off my butt and did it. In fact the WP Super Cache plugin for WordPress lets you activate Gzip compression with one click (it is called “Super Compression”).

Boy, it did speed things up, so much that I could see it visually. How so? Before activating the Gzip compression, when I loaded the homepage of the blog, I could see the sidebars loading. After the compression was activated, I was not longer able to see the sidebars loading. You can test it yourself moving between the homepage of the site and the individual category pages. You should just see the main content changing, almost as if the sidebars were not being loaded at all. (This test does not work with single post pages because I have an Awever Javascript form there, which is not hosted on the blog)

Luciano also found the code that you need to add to your .htaccess file if you are not using the WP Super Cache plugin (source here):

# Turn GZip compression on (as per http://tr.im/fnn6)

# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don’t compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary

Keep in mind that not all servers support Gzip compression. If in doubt, email the support service of your hosting company.

If your server supports it, though, I highly recommend that you give it a try. It just rocks.




No comments: