Hi,
I'd like to have a page that is using:
<?php ob_start("ob_gzhandler"); ?>
to gzip the output of the page to report the before and after document size, and display it on the final document..
Basically, the final page viewed by the browser would have a line near the end saying something like: "Original Size: 48000 bytes, Compressed Size: 20000 bytes. You have saved 28000 bytes!"
Now, the unfortunate circular nature of this is that I want to include something in the text of the page (that is compressed) that contains something about the nature of the final compression. I can't fathom how that would work, though I suspect it might be possible. Perhaps if there was a way to analyze the data after ob_gzhandler had completed, and then reinsert the data back into the buffer by capturing the data before it is flushed, by doing something at the end of the document like:
<?php
$original_size = ob_get_length();
$data = ob_end_flush();
$gzipped_size = strlen($data);
// Something to somehow insert information
// gleaned by $original_size and $gzipped_size
// into the buffer $data.
echo $data;
?>
Make sense? I don't know if it does or not. Something like this would result in slightly inaccurate file size info, because the size of the document would be calculated and then would have something inserted back into it, changing the original size by a bit, but that would be acceptable. Just being close enough to calculate a rough compression percentage would be fine.
Anyway, feedback would be much appreciated!
Peace,
Sam