I'm looking at implementing Gzip compression and output buffering.
I think I have it working, but for some reason, the page isn't displayed
for 8-10 seconds.
It seems that the compressed page is sent immediately, but the browser
hangs on to it for some reason.
http://www.dvanhorn.org/Test/Index.php Compressed
http://www.dvanhorn.org/Test/Index2.php Not compressed
Here's the top level page code:
<?
ob_start();
include('gzdoc.php');
?>
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<meta name="description" content="Web Page Status">
<meta name="GENERATOR" content="Notepad">
<? include("../headmeta.inc")?>
<title>Current status.</title>
<? include ("Header.inc")?>
</head>
<body>
<BODY BACKGROUND="../../Graphics/b_m.gif">
<? include("Index.inc") ?>
<? include("../footer.inc") ?>
<? include("../do_webtrends.php") ?>
</body>
</html>
<?
gzdocout();
?>
There are NO chars before, or after, the PHP flags.
Here is the contents of gzdoc.php.
<?
ob_start();
flush();
$debug="1";
$Level="4";
function CheckCanGzip(){
$ret = "0";
global $HTTP_ENCODING;
if (headers_sent() || connection_timeout() || connection_aborted())
$ret = "0";
if (strpos($HTTP_ENCODING,'x-gzip') != false) $ret = "x-gzip";
if (strpos($HTTP_ENCODING,'gzip' ) != false) $ret = "gzip";
return $ret;
}
function GzDocOut($Level,$debug){
$ENCODING = CheckCanGzip();
if ($ENCODING){
print "\n<!-- Use compress $ENCODING -->\n";
$Contents = ob_get_contents();
ob_end_clean();
$Size = strlen($Contents);
$Crc = crc32($Contents);
$CContents = gzcompress($Contents,$level);
$CContents = substr($CContents, 0, strlen($CContents) - 4);
Header('Content-Encoding: '.$ENCODING);
Header('Content-Length: ' . strlen($CContents));
Header('Content-Length: ' . strlen(ob_get_length));
echo $CContents;
echo pack('V',$Crc) . pack('V',$Size);
exit;
}else{
ob_end_flush();
exit;
}
}
?>
--
Where's dave? http://www.findu.com/cgi-bin/find.cgi?kc6ete-9
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]