Forum Moderators: coopster

Message Too Old, No Replies

GZIP Pro and Downfall

Is it worth it?

         

henry0

12:00 pm on Jul 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I experimented with GZIP compression using:
ob_start( 'ob_gzhandler' );

Improvement are about 10% + in loading speed gain
Of course it does not act on img that are already compressed

10% is not a huge gain, however it still is an improvement!

My question is: Is using OB the best way to do it?

And is there any underlying problems that I don’t know about when using GZIP mode?

coopster

7:51 pm on Jul 8, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



There is also
  1. Apache mod_deflate [httpd.apache.org] (Extension)
  2. Zlib Compression Functions [php.net]

Did you catch the note on the ob_gzhandler [php.net] page?


Note: You cannot use both ob_gzhandler() and
zlib.output_compression
. Also note that using
zlib.output_compression
is preferred over ob_gzhandler().

henry0

8:58 pm on Jul 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, on my way to check those links out

henry0

5:46 pm on Jul 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From your zlib link I tried a nice function
works fine, generates a gzip file, saving is a tad above 50%.
Questions:
Any problems to using it on file relying on _SESSION
Should I understand that any time the file is called a new gzip overwrite the precedent (as my test does)
so isn't it triggering server unnecessary server load?
or do I miss the point?
<<<
<?php
function compress( $srcFileName, $dstFileName )
{
// getting file content
$fp = fopen( $srcFileName, "r" );
$data = fread ( $fp, filesize( $srcFileName ) );
fclose( $fp );

// writing compressed file
$zp = gzopen( $dstFileName, "w9" );
gzwrite( $zp, $data );
gzclose( $zp );
}

function uncompress( $srcFileName, $dstFileName, $fileSize )
{
// getting content of the compressed file
$zp = gzopen( $srcFileName, "r" );
$data = fread ( $zp, $fileSize );
gzclose( $zp );

// writing uncompressed file
$fp = fopen( $dstFileName, "w" );
fwrite( $fp, $data );
fclose( $fp );
}
?>

coopster

5:59 pm on Jul 9, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You don't have to call any functions at all, all you have to do is turn it on in your zlib configuration directive ;)

henry0

7:01 pm on Jul 9, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



HMMMMM :)
No comment ..Blushing!

At least I may create a gzip file.

henry0

1:02 pm on Jul 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK Zlib does a fine job but

I have a sort of a naive question
HTML, is HTML compressed as well?
or do I need to parse HTML as PHP and add a () to the HTML page?

coopster

2:55 pm on Jul 10, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Good question. I'm guessing that any content being compressed in this manner would have to be run through the PHP parser as the directive is in
php.ini
. You'll have to test it to be certain though.

This is where Apache's extension module would be a better candidate I suppose.