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"

<Files *.gz>
  SetOutputFilter gunzip
</Files>

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.

Trackback URL for this post:

http://samat.org/trackback/61

Comments

ExtFilterDefine gunzip

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

<Files *.gz>
  SetOutputFilter gunzip
  AddType text/plain .gz
</Files>