开发者

Gzuncompress Warning in Some Browsers... What to Do?

My site caches each page daily and for some reason, some browsers (Opera and sometimes Chrome) display a warning message:

Warning: gzuncompress() [function.gzuncompress]: data error in /.../router.php on line 42

For the most part, it seems like 95% of my traffic is unaffected (or so I believe). Does anybody know of something that needs to be enabled, u开发者_如何学JAVApdated, fixed or tweaked?

Here is the code that the error message refers to:

if ( !empty($cache) && ($cache['mod_date'] * 60 * 60 * 24) > $loadTime ) {

$HTTP_ACCEPT_ENCODING = $_SERVER["HTTP_ACCEPT_ENCODING"];
if( headers_sent() )
    $encoding = false;
else if( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false )
    $encoding = 'x-gzip';
else if( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false )
    $encoding = 'gzip';
else
    $encoding = false;

$compressed = $cache['contents'];

header('Content-Type: text/html');
if ( $encoding ) {
    header("Content-Encoding: gzip");
    echo $compressed;
}
else {
    echo gzuncompress($compressed);
}

Any help would be GREATLY appreciated!


The PHP manual about gzuncompress() says: The function will return an error if the uncompressed data is more than 32768 times the length of the compressed input data…

You could also try to let PHP do the work for you using ob_gzhandler() instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜