在 Firefox(或其他浏览器)中禁用接收缓冲区
我在网络浏览器缓冲(不是缓存)方面遇到了麻烦。
我调用这个 php 脚本:
sleep(5);
echo '1st step';
echo (str_repeat(' ',256));
sleep(5);
echo '<br />';
echo '2nd step';
输出缓冲区在 php 上被禁用(我们稍后会确认)
在使用 Chromium 12 和 Firefox 5 调用此脚本时, 我得到了这个结果:
“等待”动画圈(灰色的)在大约 5 秒内运行 然后“传输”动画圈(橙色的)运行约 5 秒 最后我显示了整个结果。
正如您所期望的,我最初的目标是等待 5 秒,然后看到显示“第一步”, 再次等待 5 秒,然后看到显示“第 2 步”。
线索
当动画圈切换时,php 或 apache 不会缓冲任何内容 5秒后“等待”到“接收”(所以浏览器确实收到了一些东西 从“第一步”回声!)
我尝试将 Firefox 缓存大小设置为 0,以便绕过缓存机制..但仍然不起作用。
我读到某些浏览器可能会等到收到 256 字节后才开始显示内容。这就是为什么我添加了“echo (str_repeat(' ',256))”..但它没有解决任何问题。
我还尝试在firefox about:config中将network.buffer.cache.count和network.buffer.cache.size选项设置为0,我不知道这些选项是否与我的问题有关,但它仍然无法正常工作..
有什么想法吗?
谢谢,
I got trouble with web browsers buffering (not chaching).
I call this php script :
sleep(5);
echo '1st step';
echo (str_repeat(' ',256));
sleep(5);
echo '<br />';
echo '2nd step';
output buffer is disabled on php (we will confirm that later)
when calling this script with both Chromium 12 and Firefox 5
I got this result :
the 'waiting' animated circle (the grey one) runs during ~5sec
then the 'transferring' animated circle (the orange one) runs during ~5sec
and finally i have the whole result displayed.
My initial goal was, as you expect, to wait 5sec, then see "1st step" displayed,
wait 5sec again and then see "2nd step" displayed.
clues
php or apache doesn't buffer anything as the animated circle switch from
'waiting' to 'recieving' after 5sec (so the browser did recieve something
from the "1st step" echo !)I tried to set Firefox Cache size to 0 so the cache mechanism would be bypassed.. but still no working.
I read that some browser may wait until they recieve 256 bytes before they start display the content. That's why i added "echo (str_repeat(' ',256))".. but it doesn't solve anything.
I also tried to set network.buffer.cache.count and network.buffer.cache.size options at 0 in firefox about:config, i don't know if those option was rellated to my problem but it is still not working..
Any idea ?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
哦,我想我需要让答案成为答案,而不是评论,这样你才能接受。
HTML5 字符集嗅探缓冲区大小为 512 字节。因此,响应需要具有 512 字节的填充或设置字符集(通过
标记或 HTTP 标头)。
Oh, I guess I need to make the answer an answer, not a comment, so you can accept it.
The HTML5 charset sniffing buffer size is 512 bytes. So the response needs to either have 512 bytes of padding or set a charset (via
<meta>
tag or HTTP header).