Ken Williams > Apache-Compress-1.005 > Apache::Compress

Download:
Apache-Compress-1.005.tar.gz

Dependencies

Annotate this POD (1)

Related Modules

Apache::Dynagzip
Compress::Zlib
PerlIO::gzip
Archive::Zip
Apache::Constants
Crypt::Blowfish
Apache::AntiSpam
Apache::Filter
Archive::Tar
more...
By perlmonks.org

CPAN RT

New  1
Open  1
View/Report Bugs
Module Version: 1.005   Source  

NAME ^

Apache::Compress - Auto-compress web files with Gzip

SYNOPSIS ^

  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>

DESCRIPTION ^

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 Accept-Encoding header.

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.

TO DO ^

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.

AUTHOR ^

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.

SEE ALSO ^

perl(1), mod_perl(1), Apache::Filter(3)

syntax highlighting: