Trying to emulate mod_gunzip with Apache 2 Filters

The situation: I have gzipped content stored on an Apache 2 web server. Specifically, HTML files–they are stored in this manner to save disk space. For clients that can handle on-the-fly decompression of such files, I want the files to be sent verbatim; for clients that cannot, I want the content decompressed and sent to these clients.

mod_gunzip by Helge Oldach is an Apache 1 module made for dealing with stored gzip files. It can negotiate with a client what kind of encoding it can accept, and send the appropriate compressed or non-compressed version. Unfortunetely, at this time, this module is only available for Apache 1.

Helge Oldach notes that it should be possible to create the equivalent mod_gunzip functionality using only Apache 2 filters. To an extent, yes. I’ve done so:

ExtFilterDefine gunzip mode=output cmd="/bin/gunzip"

SetOutputFilter gunzip

This won’t do the sophisticated (well, at least more sophisticated than the Apache 2 runtime configuration directives will allow) negotiation that mod_gunzip can do, watching for certain clients and combinations of headers.

So, I’m stuck. I’ve a project I had been working on for school that involves HTML reports, collectively, that can be as large as 1.3 GB. Compressing each file with gzip decreases the collective size down to 300 MB, while still allowing the files to be viewed in most modern web browsers (apparently, at the time of this writing, this does NOT include Apple’s Safari (which happens to be used by several of my professors), though Konqueror/KHTML works fine).

Note to self: port mod_gunzip to Apache 2.

Like this article? Please support my writing! Flattr my blog (see my thoughts on Flattr), tip me via PayPal, or send me an item from my Amazon wish list.

Comments

Anonymous's picture

ExtFilterDefine gunzip intype="application/x-gzip" outtype="text/plain" mode=output cmd="/bin/zcat -c -d"

SetOutputFilter gunzip AddType text/plain .gz

Dale Osborn's picture

The comment on apache2 ExtFilterDefine gunzip was precisely what I was looking for, and works perfectly. Thank you.

ruby gem docs's picture

the first example seems to work all right. NB that also mod_deflate has an INFLATE option which might be related. =r