Jeff Davis Jeff Davis - 1 year ago 103
PHP Question

PHP flush stopped flushing in IIS7.5

We have been using php flush to "blank" a page immediately as soon as it is clicked, and also to send the navigation and main components of the page so that a page appears nearly instantly, even though sometimes the content may take a long time to load.

This has been working very well.

Recently we upgraded from IIS 7.0 to 7.5 and now flush does not work. While investigating the problem we have turned off compression for both static and dynamic files. We have also turned off output caching.

We also have zlib compression turned off and output buffering off in php.ini.

In order to test the problem we have the following script

@ini_set("output_buffering", "Off");
@ini_set('implicit_flush', 1);
@ini_set('zlib.output_compression', 0);


echo "starting...<br/>\n";
for($i = 0; $i < 5; $i++) {
print "$i<br/>\n";
print "DONE!<br/>\n";

The browser just shows the loading status (whatever that is in any browser, in IE it looks like an Ajax animated gif, in Firefox the tab will say "Connecting...") for 10 seconds, and then suddenly the entire output appears.

We have tried various combinations of flush and ob_flush and ob_end_flush based upon similar questions on this site. None of them work. Is there any way to make IIS/PHP flush the data?

Answer Source

You must set the ResponseBufferLimit value of the desired handler to a number low enough to actually flush. I recommend using 0 since it prevents IIS from doing anything but passing along what you send it from your PHP script. You can use the following command line to set the ResponseBufferLimit to 0 for the php handler (just change “NAME” to the name of the handler you want to update e.g. PHP53_via_FastCGI):

appcmd.exe set config /section:handlers "/[name='NAME'].ResponseBufferLimit:0"

Alternatively, you can edit the applicationHost.config directly and add a ResponseBufferLimit attribute the XML element.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download