mod_gzip

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 -< \
                 Out:%{mod_gzip_output_size}n = \
                 %{mod_gzip_compression_ratio}n pct." \
                 common_with_mod_gzip_info2

        CustomLog /usr/local/www/www.devco.net/log/mod_gzip.log \
                 common_with_mod_gzip_info2
</IfModule>

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.

Leave a comment

Recent Entries

  • flashpolicyd 2.0

    I wrote a multi threaded server for Adobe Flash Policy requests, some background from Adobe:Since policy files were first introduced, Flash Player has recognized /crossdomain.xml...

  • Adventures with Ruby

    Some more about my continuing experiences with ruby, in my last post I saidthe language does what you'd expect and as you'll see in my...

  • New programming language of choice - Ruby

    I have fallen out of love with Perl some time ago, I cannot point to one specific thing about it that put me off, I...

  • On working from home

    I've not been posting much here, work has been incredibly manic the last while, especially I need to still finish off my SSO posts with...

  • Rework of puppet facts for /etc/facts.txt

    Previously I blogged a custom fact that reads /etc/facts.txt to build up some custom facts for use in Puppet manifests, well I've since learned a...

Close