如何找出使用HTTP协议缓存数据的位置?

时间:2011-07-04 19:56:00

标签: php zend-framework http apache2

我试图使用php5 / apache2的早期刷新来执行一些代码,渲染一些json,然后执行代码的另一部分需要几秒但不会产生任何响应。 到目前为止的基本代码是:

@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);

echo 'Page loading'; // code to render;
ob_flush();
flush();

sleep(29); // LONG time code to execute

上一个示例不起作用。我的意思是它会回应“页面加载”#39; 29秒后。 如果我查看了我的http响应:

(Status-Line)   HTTP/1.1 200 OK
Date    Mon, 04 Jul 2011 19:49:19 GMT
Server  Apache/2.2.11 (Win32) mod_ssl/2.2.11 OpenSSL/0.9.8k PHP/5.3.0
X-Powered-By    PHP/5.3.0
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control   no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma  no-cache
Keep-Alive  timeout=5, max=100
Connection  Keep-Alive
Transfer-Encoding   chunked
Content-Type    text/html

我的问题不是为什么它不起作用?但是我怎样才能检查我的字符串被缓冲的位置? 我知道有不同的缓冲区: - php output_buffer,php zlib.buffer - apache mode_deflate / gzip - 浏览器缓冲

所有php输出缓冲都关闭,apache mode_deflate被激活但是你可以看到转移编码是" chunked"。 我不知道如何找出我的问题在哪里,我使用HttpFox来查看标题,我尝试获取HTTP请求的内容,HttpFox说内容在29秒完成之前没有准备好。

有什么建议吗?

2 个答案:

答案 0 :(得分:0)

嗯,你试过ob_get_level()吗?

答案 1 :(得分:0)

Marc B是对的......

我必须创建一个1000的循环,并激活output_buffering

$var = 1000;
while(--$var)
    echo 'Page loading'; // code to render;

能够在睡眠前看到结果。

我必须循环100,使用output_buffering = off来获得相同的结果。