Apache::Compress - Auto-compress web files with Gzip
PerlModule Apache::Compress # Compress regular files - decides whether to compress by # examining the Accept-Encoding header <FilesMatch "\.blah$"> SetHandler perl-script PerlHandler Apache::Compress </FilesMatch> # Compress output of Perl scripts PerlModule Apache::Filter <FilesMatch "\.pl$"> SetHandler perl-script PerlSetVar Filter on PerlHandler Apache::RegistryFilter Apache::Compress </FilesMatch> # Guess based on user-agent <FilesMatch "\.blah$"> SetHandler perl-script PerlSetVar CompressDecision User-Agent PerlHandler Apache::Compress </FilesMatch>
This module lets you send the content of an HTTP response as gzip-compressed data. Certain browsers (Netscape, IE) can request content compression via the
Accept-Encoding header. This can speed things up if you're sending large files to your users through slow connections.
Browsers that don't request gzipped data will receive regular noncompressed data.
Apparently some older browsers (and maybe even some newer ones) actually support gzip encoding, but don't send the
Accept-Encoding header. If you want to try to guess which browsers these are and encode the content anyway, you can set the
CompressDecision variable to
User-Agent. The default
CompressDecision value is
Header, which means it will only look at the incoming
Note that the browser-guessing is currently using a regular expression that I don't think is very good, but I don't know what user agents to support and which not to. Please send me information if you have any, especially in the form of a patch. =)
This module is compatibile with Apache::Filter, so you can compress the output of other content-generators.
Compress::Zlib provides a facility for buffering output until there's enough data for efficient compression. Currently we don't take advantage of this facility, we simply compress the whole content body at once. We could achieve better memory usage if we changed this (at a small cost to the compression ratio). See Eagle book, p.185.
Ken Williams, KWILLIAMS@cpan.org
Partially based on the work of several modules, like Doug MacEachern's Apache::Gzip (in the Eagle book but not on CPAN), Andreas Koenig's Apache::GzipChain, and an unreleased module by Geoffrey Young and Philippe Chiasson.
perl(1), mod_perl(1), Apache::Filter(3)