Reputation: 3823
Let imagine we have site what every second check is there any new messages:
$(function(){
setInterval(function(){
$.ajax({
url: 'message_check.php',
success: function(data){
if(data)$('#someDiv').html('NEW MESSAGE!');
}
});
},1000);
});
Now someone opened 3 tabs with different pages of my site.
How many call I'll get every second, three or one?
if one then how tabs sinc?
if three then we lost very very much performance, right?
Noticed what Firebug show same console for different pages of same site. It means what FireFox in my case (and I hope other browser too) understand what it same site and can avoid multiple calls.
I think about saving result into cookie and make call only if it's not "fresh", but don't want to reinvent the wheel.
Upvotes: 0
Views: 767
Reputation: 2848
I think its depends on the browser you use. Some browsers use only 2 concurrect connections to the server, hence you will get up to 2 concurrent hits from your multi-tab browser client. So if you javascript generates multiple requests, they will be quied & managed by the browser.
Upvotes: 1