Firefox是否同步同一页面的请求? [英] Does Firefox synchronize requests for the same page?

查看:127
本文介绍了Firefox是否同步同一页面的请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Firefox 3.6.6。

I'm using Firefox 3.6.6.

我有一个名为 index.php 的PHP脚本以下代码:

I have a PHP script called index.php with the following code:

<?php
sleep(20); die(time());
?>

我打开两个浏览器标签,将URL复制到每个标签中,然后快速点击每个标签。第一个标签在20秒内完成。第二个标签在短短40秒内完成。

I open two browser tabs, copy the URL into each of them, and then quickly hit enter in each tab. The first tab completes in just over 20 seconds. The second tab completes in just over 40 seconds.

我在IE中进行相同的实验,两个脚本在一秒钟内完成,大约20秒。

I do the same experiment in IE and both scripts complete within a second of each other, around 20 seconds.

这是预期的行为吗?导致我测试它的实际脚本是一个同步过程。我希望任何试图执行两次的人都收到一个错误,该错误表明该进程已在进行中,而不是让浏览器坐在那里等待它再次执行它。

Is this expected behavior? The actual script that caused me to test this is a synchronous procedure. I want any person attempting to execute it twice to receive an error that the process is already in progress, rather than having the browser sit there and wait until it can execute it a second time.

如果这是Firefox的工作原理,它如何确定页面何时重复并且它应该排队请求而不是同时运行它们?

If this is how Firefox works, how does it determine when a page is a duplicate and that it should queue up the requests rather than run them simultaneously?

我可以通过在末尾放一个垃圾GET字符串来欺骗它,例如 index.php index.php?JUNK = 1 都在20秒左右完成。

I can fool it by putting a junk GET string on the end, e.g. index.php and index.php?JUNK=1 both complete at around 20 seconds.

推荐答案

这是缓存机制:如果禁用所有缓存,则不会发生问题。显然,FF开发人员检查当请求仍在加载时它可能是可缓存的,所以它等待第一个,然后才决定不使用缓存,然后才调度第二个请求(你可以在时间戳中检查它)你的日志文件)。

It's the caching mechanism: if you disable all caching the problem does not occur. Apparently, the FF developers have a check that when a request is still loading it might be cachable, so it waits for the first, only then decides not to use cache, and only then dispatches the second request (you can check that in the timestamp of your log files).

您可以尝试使用一些无缓存标头&一个flush()数据到客户端,也许它可以确定缓存不是接收标头时的选项,虽然我怀疑只有在加载内容后才进行缓存检查。

You could try to play around with some no-cache headers & a flush() of data to the client, perhaps it can determine caching is not an option when receiving headers, although I suspect the cache check is done only after the content is loaded.

这篇关于Firefox是否同步同一页面的请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆