这是一个奇怪的现象。我正在慢慢地在实时服务器上重建网站。站点的某些部分已被重建,因此代码被放置在主目录的子目录中(即:/mysite/newcode)。
我已经使用 ob_start("ob_gzhandler"); 成功对旧站点进行了 gzip 压缩。因此,我为新代码应用了完全相同的代码。然而,由于某种奇怪的原因,它返回时未经过 gzip 压缩。我已经检查了 http://www.whatsmyip.org/http_compression/ 和 http://www.gidnetwork.com/tools/gzip-test.php。我不太明白如果 gzip 处理程序作为新旧代码的第一行(在任何输出之前)之一包含在内,为什么它不会对新代码进行 gzip 压缩。
PHP 5.1.6
阿帕奇2.0
森托斯5
This is an odd one. I am slowly rebuilding a website on a live server. Some sections of the site have been rebuilt and therefore the code is placed in a subdirectory of the home dir (ie:/mysite/newcode).
I had successfully gzipped the old site using ob_start("ob_gzhandler"); So, i have applied the exact same code for the new code. However, for some odd reason, its returning as not gzipped. I have checked on http://www.whatsmyip.org/http_compression/ and http://www.gidnetwork.com/tools/gzip-test.php. I can't quite understand why it wouldn't be gzipping the new code if the gzip handler is included as one of the very first lines (before any output) on both old and new code.
PHP 5.1.6
Apache 2.0
Centos 5
发布评论
评论(2)
http://docs.php.net/ob_gzhandler 说:
Could this be the cause of your problem?
编辑:你可以用类似的东西来测试它
http://docs.php.net/ob_gzhandler says:
Could this be the cause of your problem?
edit: You can test this with something like
发现问题,不确定是否在任何地方记录...
如果您使用 ob_start("ob_gzhandler");你要刷新你的内容,你必须使用ob_flush(),而不是flush()。使用flush会消除压缩。
Found out the problem, not sure if documented anywhere...
If you use ob_start("ob_gzhandler"); and you what to flush your content, you must use ob_flush(), not flush(). Using flush will throw out the compression.