<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ls /proc &#187; buffer</title>
	<atom:link href="http://www.lsproc.com/blog/tag/buffer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lsproc.com/blog</link>
	<description>lsproc.com</description>
	<lastBuildDate>Fri, 21 May 2010 14:29:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>nginx+factcgi 下使用 ob_flush</title>
		<link>http://www.lsproc.com/blog/use_ob_flush_on_nginx_fastcgi/</link>
		<comments>http://www.lsproc.com/blog/use_ob_flush_on_nginx_fastcgi/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 03:45:23 +0000</pubDate>
		<dc:creator>lostsnow</dc:creator>
				<category><![CDATA[Linux&Webserver]]></category>
		<category><![CDATA[buffer]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ob_flush]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.lsproc.com/blog/?p=376</guid>
		<description><![CDATA[转载时请标明文章原始出处和作者信息, 作者: lostsnow.http://www.lsproc.com/blog/use_ob_flush_on_nginx_fastcgi/ Nginx与php-cgi是两个独立的程序，通过TCP或Unix套接字通信，不像Apache那样是集成在一起的。所以，Nginx有fastcgi 缓冲区，数据超出缓冲区大小、或程序执行完，才会将内容输出到客户端。如果要使用ob_flush，不能开启gzip压缩输出。 nginx.conf: fastcgi_buffer_size 4k; fastcgi_buffers 8 4k; gzip off; php.ini: output_buffering = Off &#60;?php set_time_limit(0); ob_end_clean(); ob_implicit_flush(1); for($i = 0; $i &#60; 10; $i++) { echo $i . &#34;&#60;br /&#62;\n&#34;; echo str_repeat(&#039;&#039;, 1024*4); sleep(1); } 其中 echo str_repeat('', 1024*4); 使得fastcgi_buffer_size 4k; 的缓冲区满，从而输出内容到浏览器 参考: http://blog.s135.com/nginx_php_v6/2/1/ -- EOF -- Related Posts2010-05-21 -- Nginx/PHP [...]]]></description>
			<content:encoded><![CDATA[<p>转载时请标明文章原始出处和作者信息, 作者: <a href="http://www.lsproc.com/blog/">lostsnow</a>.<br /><a href="http://www.lsproc.com/blog/use_ob_flush_on_nginx_fastcgi/">http://www.lsproc.com/blog/use_ob_flush_on_nginx_fastcgi/</a></p>
<p>Nginx与php-cgi是两个独立的程序，通过TCP或Unix套接字通信，不像Apache那样是集成在一起的。所以，Nginx有fastcgi 缓冲区，数据超出缓冲区大小、或程序执行完，才会将内容输出到客户端。<strong>如果要使用ob_flush，不能开启gzip压缩输出。</strong></p>
<p>nginx.conf:</p>
<pre class="brush: text">fastcgi_buffer_size 4k;
fastcgi_buffers 8 4k;
gzip off;</pre>
<p>php.ini:</p>
<pre class="brush: text">
output_buffering = Off
</pre>
<pre class="brush: php">
&lt;?php
set_time_limit(0);
ob_end_clean();
ob_implicit_flush(1);

for($i = 0; $i &lt; 10; $i++)
{
    echo $i . &quot;&lt;br /&gt;\n&quot;;
    echo str_repeat(&#039;&#039;, 1024*4);
    sleep(1);
}
</pre>
<p>其中 echo str_repeat('', 1024*4);<br />
使得fastcgi_buffer_size 4k; 的缓冲区满，从而输出内容到浏览器</p>
<p>参考: http://blog.s135.com/nginx_php_v6/2/1/
<p>-- EOF --</p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li>2010-05-21 -- <a href="http://www.lsproc.com/blog/nginx_php_pathinfo_securit/" title="Nginx/PHP 文件类型错误解析漏洞：fix_pathinfo">Nginx/PHP 文件类型错误解析漏洞：fix_pathinfo</a> (2)</li><li>2010-04-12 -- <a href="http://www.lsproc.com/blog/nginx_userid_decode/" title="nginx userid 模块客户端 cookie 解码">nginx userid 模块客户端 cookie 解码</a> (0)</li><li>2008-06-15 -- <a href="http://www.lsproc.com/blog/lighttpd_phpfastcgi_config/" title="lighttpd + PHP(fastcgi) 配置">lighttpd + PHP(fastcgi) 配置</a> (0)</li><li>2009-03-29 -- <a href="http://www.lsproc.com/blog/nginx_ssl_config/" title="Nginx SSL 配置">Nginx SSL 配置</a> (23)</li><li>2008-10-23 -- <a href="http://www.lsproc.com/blog/nginx_rewrite_param/" title="nginx rewrite 的一些参数  ">nginx rewrite 的一些参数  </a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.lsproc.com/blog/use_ob_flush_on_nginx_fastcgi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
