【发布时间】:2013-12-24 17:00:40
【问题描述】:
<?php
header("X-Accel-Buffering: no");
header('Content-Encoding: none;');
//and yet other headers
ob_end_flush();
flush();
sleep(1);
echo time().PHP_EOL;
flush();
sleep(2);
echo time().PHP_EOL;
所以,当我使用 Apache + php,并在 Apache 和 php 中关闭缓冲时, 并获取此 scipt 的页面,我会在 firebug 中看到,等待响应的时间约为 0(已使用 localhost)
但是,如果用 nginx 和 php-fpm 相同的方式,我会看到,等待响应的时间大约是 1 秒。
因此,nginx(或 php-fpm)不想立即发送标头。为什么? 我该如何完成我的任务?
PS 根据不同的论坛
nginx 配置 - proxy_buffering 关闭; fastcgi_max_temp_file_size 0; fastcgi_keep_conn 开启; gzip 关闭;
php 配置文件 output_buffering = 关闭
【问题讨论】:
-
我们看到您标记了 nginx,但您已多次提及 Apache。请澄清您的问题,这是关于 Apache 还是 Nginx?
-
Nginx !!(像apache这样的例子,什么有效。但是nginx不能按我的意愿工作,所以关于nginx的问题)
标签: nginx php output-buffering