Forum Moderators: coopster

Message Too Old, No Replies

gzip compression and chunked cache

Can I use them both at the same time?

         

twist

9:48 pm on Mar 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have been using this code for outputting pages using gzip compression,

$gzip_contents = ob_get_contents();
ob_end_clean();

$gzip_size = strlen( $gzip_contents );
$gzip_crc = crc32( $gzip_contents );

$gzip_contents = gzcompress( $gzip_contents, 9 );
$gzip_contents = substr( $gzip_contents, 0, strlen( $gzip_contents ) - 4 );

echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack( 'V', $gzip_crc );
echo pack( 'V', $gzip_size );

I want to implement the caching from this tutorial someone from here pointed me to on the sitepoint forums, under the heading Chunked Buffering

www.sitepoint.com/article/php-anthology-2-5-caching/2

The tutorial wants me to add a ob_end_clean, but I already am using it in the gzip code, how would I mix these two together if that is even possible?

jatar_k

1:54 am on Mar 26, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you figure this out, or get any farther, on this twist?

twist

2:53 am on Mar 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if( $do_gzip_compress ) {
ob_clean();
ob_start();
ob_implicit_flush(0);

echo $header . $body . $footer;

$gzip_contents = ob_get_contents();
ob_end_clean();

$gzip_size = strlen( $gzip_contents );
$gzip_crc = crc32( $gzip_contents );

$gzip_contents = gzcompress( $gzip_contents, 9 );
$gzip_contents = substr( $gzip_contents, 0, strlen( $gzip_contents ) - 4 );

echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack( 'V', $gzip_crc );
echo pack( 'V', $gzip_size );
}
else {
ob_end_clean();
echo $header . $body . $footer;
}

I think I got it working.

jatar_k

4:15 am on Mar 26, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



nice