Thread Kompression von Websites (11 answers)
Opened by [E|B] at 2005-01-04 15:20

esskar
 2005-01-04 21:00
#3974 #3974
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
rentiert sich eigentlich erst ab einer gewissen größe

in $output steht alles, was an den browser soll - ohne http header
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use Compress::Zlib

my $cntlength = length $output;
my $header = "Content-Type: text/html\n";

if($ENV{HTTP_ACCEPT_ENCODING} =~ /gzip/oi and $cntlength > 200)
{
  my $compress = Compress::Zlib::memGzip($output);
  my $length = length($compress);

  $header .= "Content-Encoding: gzip\n";
  $header .= "Content-Length: $length\n";

  $output = $compress;
}  

print "$header\n$output";
\n\n

<!--EDIT|esskar|1104869841-->

View full thread Kompression von Websites