在当前页面停止之前,同一时间只能加载一个页面


The same page at the same time can only load one until current page stopped

我用服务器发送事件来做这件事

我有一个问题,那就是我只能在同一时间打开同一个页面

对于一个而不是两个或更多(因为他们只会加载它,直到当前页面停止),

这也与session_write_close()无关。

这是我在服务器上测试的代码

(有两个不同的服务器,XAMPP&EasyHP和OSX内置PHP),

我将其重命名为"test.php":

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

当我运行test.php时,它看起来一切都很顺利,

但如果我在另一个选项卡中打开同一页,它就什么都没给我(冻结),

有人能告诉我怎么了吗?这有限制吗?

编辑:2014/10/10

虽然这个代码不在演示中,但它看起来像是在

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

存在于你的代码中,也许是谷歌Chrome漏洞,我会尽快检查出来。。

--

解决方案

这个问题只发生在谷歌Chrome上,所以我更改了

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

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

它一直有效,直到您在Apacheconfig中达到每个IP的限制连接

或浏览器每个服务器的最大连接数:D

此代码适用于我:

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