Trying to emulate mod_gunzip with Apache 2 Filters

Tags: •  •  • 

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.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

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>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
More information about formatting options