Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flush() doesn't work in Firefox 4

Tags:

php

firefox

flush

I noticed that the php flush(); doesn't work in Firefox 4 beta 7, as it works in 3.6.12.

I recently installed firefox 4 beta 7, and the contents are not being flush immediately when flush() is called. It used to work fine in 3.6.12. Is there any thing else that could provide me with the flushing functionality.

I've tried

flush();  
@ob_flush();

I also tried the following code at the top of the page.

@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
for ($i = 0; $i < ob_get_level(); $i++) { ob_end_flush(); }
   ob_implicit_flush(1);

By the way, I use php on XAMPP/Apache. Thanks.


I found that setting content type to text/plain works, but it just outputs plain text and not html content.

like image 237
Ctroy Avatar asked Nov 20 '10 04:11

Ctroy


2 Answers

You're not seeing ghosts - I've experienced the same difference between FF3.6 and FF4.

Here's a work around: add an

echo str_repeat(" ", 1024);

before the output that needs to be flushed. You can put it for example in the <head>.

My theory is that FF4, like apparently IE and Safari, have a small buffer that needs to be filled before incremental rendering kicks in.

like image 165
Erwin Wessels Avatar answered Nov 04 '22 15:11

Erwin Wessels


flush will function identically server-side regardless of the browser. If the client is displaying things differently, there's not a lot you can do server-side to fix it.

like image 1
meagar Avatar answered Nov 04 '22 15:11

meagar