1

I'm doing this with Server-Sent Event,

and I have a problem which is I can only open the same page at the same time

for one not two or more(because they will only load it until the current page stopped),

and it's not something about session_write_close() also.

Here's the code that I tested on my server

(with two different server, XAMPP & EasyPHP and OSX built-in PHP too),

I rename it to "test.php":

<?php
set_time_limit(0);
while(true)
{
    echo time() . '<br>';
    ob_flush();
    flush();
    sleep(1);
}
?>

When I running test.php, it looks everything going well,

but if I open the same page in another tab, it's just gave me nothing(freezing),

Can anyone tell me what's wrong? Is there an limit for this?

EDIT: 2014/10/10

Although this code is not in the demo, but it looks like it's occurred when

header('Cache-Control: no-cache');

was existed in your code, maybe it's Google Chrome bug, I will check it out sooner..

--

SOLUTION

This problem only occurred on Google Chrome, so I change

header('Cache-Control: no-cache');

to

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

and it's worked, until you reach the limit connection per IP in Apache config

or the max connections per server of browser :D

Community
  • 1
  • 1

1 Answers1

0

This code works for me:

<?php
session_start();
session_write_close();
set_time_limit(5);
while(true)
{
    echo time() . '<br>';
    ob_flush();
    flush();
    sleep(1);
}
?>
boomoto
  • 311
  • 1
  • 9
  • Thanks, so it's still about `session_write_close()`, but my code is not that really easy.. I will find it out.. thank you! – Yami Odymel Oct 10 '14 at 02:41
  • 1
    It looks like it's caused by `header('Cache-Control: no-cache');` in Google Chrome, just let you know if you have same problem in the future :D – Yami Odymel Oct 10 '14 at 05:34