Select Page
NOTE: This is a static archive of an old blog, no interactions like search or categories are current.

As I mentioned the other day I want to start fiddling with mod_gzip, I did just that and am quite pleased with the result.

More details on the full entry.

Installing mod_gzip on my FreeBSD machine was as expected trivial with the ports system. Configuring it can be quite a mission, it has a zillion directives and some does not seem to always work the way you would think. A reference for the config can be found here.

The main issue I ran into is that while I tell the config I want all content of a specific content type compressed, it just does not do it for all types of files, I could not convince it to compress output from my php files by mime type so resorted to enabling it by file extension for .php files.

My config snippet in my virtual server directive for this site is below:

<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_can_negotiate Yes
mod_gzip_keep_workfiles No
mod_gzip_minimum_file_size 500
mod_gzip_maximum_file_size 500000
mod_gzip_maximum_inmem_size 60000
mod_gzip_min_http 1000
mod_gzip_handle_methods GET
mod_gzip_dechunk Yes
mod_gzip_add_header_count Yes
mod_gzip_send_vary On
# compress these
mod_gzip_item_include         mime       ^text/html$
mod_gzip_item_include         mime       ^text/plain$
mod_gzip_item_include         mime       ^text/css$
mod_gzip_item_include         mime       ^application/x-javascript$
mod_gzip_item_include         mime       ^application/xml$
mod_gzip_item_include         file       \.php$
# dont compress these
mod_gzip_item_exclude         file       \.jpg$
mod_gzip_item_exclude         file       \.gif$
mod_gzip_item_exclude         file       \.png$
mod_gzip_item_exclude         reqheader  "User-agent: \
Mozilla/4.0[678]"
LogFormat  "%h %l %u %t \"%V %r\" %<s %b mod_gzip:\
%{mod_gzip_result}n In:%{mod_gzip_input_size}n -

After a day or so I can see from my log very impressive results. My .php file output compresses around 75%, my XML files for RSS feeds about 80% and I was quite surprised to see quite a few aggregators support gzip compression and even some of the crawlers out there.

For now I am quite happy with this addition.