Gzip compression for CGI and perl scripts with CGI::WebGzip

Home » Perl » Gzip compression for CGI and perl scripts with CGI::WebGzip
Date: 2006-01-15
Link: http://perl.devquickref.com/perl-Gzip-compression-cgi-perl-scripts-WebGZip.html

Gzip compression for CGI and perl scripts with CGI::WebGzip

 
1) download following perl module
http://search.cpan.org/CPAN/authors/id/K/KO/KOTEROV/CGI-WebGzip-0.13.tar.gz
2) untar archive ( tar -zxvf CGI-WebGzip-0.13.tar.gz )
3) make (or nmake on windows)
4) copy blib/lib to your script directory in \\\"lib\\\"
5) add following lines in top of your script
#--------------------
use lib \\\'./lib/\\\';
use CGI::WebGzip(9); # compression can be: 1 to 9. 1 - minimal compression; 9 max
#--------------------
6) test
normal size:
wget http://yoursite.com/script.cgi
compressed size:
wget --header \\\"Accept-Encoding: gzip,deflate\\\" http://yoursite.com/script.cgi
if there are any problems you could use on the top of your scripts
and errors will be displayed in your browser following code:
use CGI::Carp \\\"fatalsToBrowser\\\";
7) references:
http://search.cpan.org/~koterov/CGI-WebGzip-0.13/
http://www.annocpan.org/~KOTEROV/CGI-WebGzip-0.13/WebGzip.pm