For example, to compress all HTML files on the fly, do this:
<Files *.html>
SetHandler perl-script
PerlHandler Apache::OutputChain Apache::GzipChain Apache::PassFile
</Files>
Browsers are supposed to declare that they can handle compressed
input by setting the Accept-Encoding header.
Unfortunately, many browsers cannot handle it, even if they claim
that they can. Apache::GzipChain keeps a list of
user agents, and also looks at the User-Agent
header to check for browsers known to accept compressed output.
As an example, if you want to return compressed files that will in
addition pass through the Embperl module, you
would write:
<Location /test>
SetHandler perl-script
PerlHandler Apache::OutputChain Apache::GzipChain \
Apache::EmbperlChain Apache::PassFile
</Location>
Watch the access_log file to see how many bytes
were actually sent, and compare that with the bytes sent using a
regular configuration.
Notice that the rightmost PerlHandler must be a
content producer. Here we are using
Apache::PassFile, but you can use any module that
creates output.
The cool thing about these modules is that they
don't require any modification of the code. To
enable or disable them, only httpd.conf has to
be tweaked.