PHP flash stopped flushing in IIS7.5

We immediately used php-flush to “empty” the page as soon as it was clicked, and also to send navigation and the main components of the page so that the page would display almost instantly, although sometimes the content may take a long time to load.

It works very well.

We recently upgraded from IIS 7.0 to 7.5, and now the flash does not work. When investigating the problem, we turned off compression for both static and dynamic files. We also disabled output caching.

We also disabled zlib compression and buffering output in php.ini.

To check the problem, we have the following script

@ini_set("output_buffering", "Off"); @ini_set('implicit_flush', 1); @ini_set('zlib.output_compression', 0); ob_start(); echo "starting...<br/>\n"; for($i = 0; $i < 5; $i++) { print "$i<br/>\n"; ob_end_flush(); ob_flush(); flush(); ob_start(); sleep(2); } print "DONE!<br/>\n"; 

The browser simply shows the download status (regardless of what is in any browser, in IE it looks like an animated Ajax gif, in Firefox the tab will say “Connection ...”) for 10 seconds, and then all of a sudden output.

We tried to use different combinations of flash and ob_flush and ob_end_flush based on similar questions on this site. None of them work. Is there a way to do IIS / PHP to clear the data?

+7
source share
7 answers

You must set the ResponseBufferLimit value for the selected handler to a number low enough for the actual reset. I recommend using 0 because it does not allow IIS to do anything other than transmit what you send from your PHP script. You can use the following command line to set ResponseBufferLimit to 0 for the php handler (just change "NAME" to the name of the handler you want to update, for example PHP53_via_FastCGI):

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

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

+7
source share

There is another way to set a response limit using IIS Manager:

  • On the server’s main page, in the "Management" section, select "Configuration Editor";
  • in the "Section" section, enter "system.webServer / handlers";
  • next to "(Collection)" click "..." OR check the item "(Collection)" and in the "Actions" and "Element" section, select "Editing Elements";
  • scroll down until you find your version of PHP under "Name";
  • below, properties that can be edited manually are displayed, including responseBufferLimit, which must be set to 0 for flush () to work.

Big Pro is that you can edit properties for everything, not just PHP, and you can work with different versions (or even installations of the same version) of PHP.

NTN

+27
source share

What I do is that I use the following function:

 function flush_buffers(){ ob_end_flush(); ob_flush(); flush(); ob_start(); } 

So in your code:

 ob_start(); flush_buffers(); echo "starting...<br/>\n"; for($i = 0; $i < 5; $i++) { print "$i<br/>\n"; flush_buffers(); sleep(2); } 

It should work flawlessly :-)


Here is the working code (with the correct Content-Type ):

 <?php header("Content-Type: text/html; charset=utf-8"); function flush_buffers(){ ob_end_flush(); ob_flush(); flush(); ob_start(); } ob_start(); flush_buffers(); echo "starting...<br/>\n"; for($i = 0; $i < 60; $i++) { flush_buffers(); print "$i<br/>\n"; flush_buffers(); sleep(2); } flush_buffers(); print "DONE!<br/>\n"; ?> 
+4
source share

Enter the following command as an administrator in Powershell:

 C:\Windows\System32\inetsrv> .\appcmd.exe set config /section:handlers "/[name='PHP_via_FastCGI'].ResponseBufferLimit:0" 

Expected Result:

The applicable configuration changes in the "system.webServer / handlers" section for "MACHINE / WEBROOT / APPHOST" when configuring the comm it path "MACHINE / WEBROOT / APPHOST"

For more information, see: http://www.coastrd.com/cgioniis7

Basically, we need to tell FastCGI to change its ResponseBufferLimit . This cannot be done using the IIS management console (only 7.5 verified)

+4
source share

I'm a little late to the party, but thought I'd add how to do this using web.config.

 <?xml version="1.0" encoding="UTF-8"?> <configuration> <!--- other stuff here ---> <handlers> <remove name="ISAPI-dll" /> <add name="ISAPI-dll" path="*.dll" verb="*" type="" modules="IsapiModule" scriptProcessor="" resourceType="File" requireAccess="Execute" allowPathInfo="true" preCondition="" responseBufferLimit="0" /> </handlers> </system.webServer> </configuration> 
+2
source share

It is up to the web server whether it decides to overturn the content or send it through an encoded encoding. Therefore, although PHP may ask the server to output data to the client, it cannot force the server to use encoded encoding.

In this article, you clearly need to set the transfer encoding for IIS (see the bit about ISAPI) to send data to the server - you try to do the same in the script.

IME, most scenarios where this is a problem can be better solved ....

 register_shutdown_function('do_slow_stuff'); ....generate html content.... exit; // closes stdin/stdout, but shutdown fn will still be called function do_slow_stuff() { .... } 
+1
source share

Here's another way to do this using web.config (the @Jules method didn't work for me with IIS 8.0). Of course, you will want to replace the PHP versions and the paths to them are actually on your computer.

This allows you to use events sent by the server!

 <configuration> <system.webServer> <handlers> <remove name="PHP53_via_FastCGI" /> <remove name="PHP54_via_FastCGI" /> <remove name="PHP55_via_FastCGI" /> <add name="PHP53_via_FastCGI" path="*.php" verb="GET,HEAD,POST" type="" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.3\php-cgi.exe" resourceType="Either" requireAccess="Script" allowPathInfo="true" preCondition="" responseBufferLimit="0" /> <add name="PHP54_via_FastCGI" path="*.php" verb="GET,HEAD,POST" type="" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.4\php-cgi.exe" resourceType="Either" requireAccess="Script" allowPathInfo="true" preCondition="" responseBufferLimit="0" /> <add name="PHP55_via_FastCGI" path="*.php" verb="GET,HEAD,POST" type="" modules="FastCgiModule" scriptProcessor="C:\Program Files (x86)\PHP\v5.5\php-cgi.exe" resourceType="Either" requireAccess="Script" allowPathInfo="true" preCondition="" responseBufferLimit="0" /> </handlers> </system.webServer> </configuration> 
0
source share

All Articles