HTTP parallel requests and AJAX/polling
Okay, so we all know that most modern browsers (without tweaking) are set to 4 parallel HTTP requests at a time to a single domain/subdomain, but how does long-polling AJAX affect this?
Say I have a long-po开发者_开发问答ll on a 15 second interval. While the browser is waiting for a response during those 15 seconds, does that still eat up one of the 4 parallel lines effectively making any new tabs or page loads open to only 3 parallel HTTP requests?
- It's not always 4, often it's 2.
- It is configurable to a higher number on the client side in many browsers.
- Yes it does eat up one of the parallel connections.
You can have 2 concurrent requests via XHR..if you use more you might end up with unexpected results.
Use a Request Queue for more than 2 requests...each one being made after the previous one ends...
Some popular JS libraries implement a queue and can be used, or you could create one easily.
精彩评论