Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Can't flush buffer with NginX

$
0
0

I'm trying to proof a comet style page and to start it up I thought I would set a simple counter in PHP to output 0->3 with a one second delay between each output and flush it to screen each second.  Problem is nothing I have tried has actualy managed to flush the buffer out.  It just sits there with the loading spinner and after 4 seconds dumps the lot onto the screen at once.  I have been diging about and have set the nginx config to the following:

user www-data;

worker_processes  1;



error_log  /var/log/nginx/error.log;

pid        /var/run/nginx.pid;



events {

    worker_connections  1024;

     multi_accept on;

}



http {

    include       /etc/nginx/mime.types;



    access_log    /var/log/nginx/access.log;



    sendfile        on;

    tcp_nopush     on;



    #keepalive_timeout  0;

    keepalive_timeout  65;

    tcp_nodelay        on;



#----------------------------------------------

#    fastcgi_keep_conn on;

    proxy_buffering off;

    gzip off;

#----------------------------------------------

    gzip_disable "MSIE [1-6]\.(?!.*SV1)";



    include /etc/nginx/conf.d/*.conf;

    include /etc/nginx/sites-enabled/*;

}

I had to comment out the fastcgi_keep_con on; as this wasn't recognised.

 

The following is the PHP page.

<?php



ini_set('zlib.output_compression', 'Off');

ini_set('output_handler',"");

ini_set('implicit_flush',1);

set_time_limit(0);



ob_start();

header("Cache-Control: no-cache, must-revalidate");

flush();

ob_flush();

 

    for ($i=0;$i<4;$i++) {

      echo "$i <br>";

      ob_flush();

      flush();

      sleep(1);

    }



ob_end_clean();

?>

Any ideas what I'm missing here?


Viewing all articles
Browse latest Browse all 13200

Trending Articles