Multiple instances of PHP script will not be loaded at the same time in the same browser from the same url

I am trying to run two instances of a php script to run at the same time. I have a script, 'test.php':

<p><?php echo time(); ?> Sleeping...</p>
<?php sleep(5); ?>
<p><?php echo time(); ?> done</p>

      

If I load the page on two browser tabs at the same time, I get this:

1446855680 Sleeping ...

1446855685 done

and this:

1446855686 Sleeping ...

1446855691 done

One instance is blocked until other loads are loaded. This happens on both Firefox and Chromium.

If I do a second identical script, 'test2.php', or rewrite two urls into the same script and load two pages in different tabs, I get this:

1446855862 Sleeping ...

1446855867 done

and this:

1446855863 Sleeping ...

1446855868 done

Both instances are loaded at the same time. Thus, these are identical URLs that are blocked.

How can I get two script instances with the same url to download / run at the same time?

+1


source to share


1 answer


As VolkerK pointed out and your testing has confirmed that Firefox / Chrome is making requests for the same URL in sequence. In practice, however, this is not a problem as users usually do not load the same page twice, and for a script that serves data for Ajax requests, the URLs will be different as different parameters are added.



If you want to bypass this mechanism, you can add a random parameter (should be different in different browser tabs) to the URL, i.e. url.to/your/script?urlID=4821de7e524cf762deab6ed731343466

... The random parameter causes the browser to see two different URLs and thus perform a parallel download.

0


source







All Articles