某些浏览器中的 Gzuncompress 警告...该怎么办?

发布于 2024-11-28 01:38:00 字数 894 浏览 0 评论 0原文

我的网站每天都会缓存每个页面,由于某种原因,某些浏览器(Opera 和有时是 Chrome)会显示一条警告消息:

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

在大多数情况下,我的流量似乎 95% 不受影响(至少我相信是这样)。有人知道需要启用、更新、修复或调整的东西吗?

以下是错误消息所指的代码:

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);
}

任何帮助将不胜感激!

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, updated, 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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唯憾梦倾城 2024-12-05 01:38:00

关于 gzuncompress() 的 PHP 手册说:如果未压缩的数据超过压缩输入数据长度的 32768 倍,该函数将返回错误...

您也可以尝试使用 ob_gzhandler() 代替。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文