9.2. Connection Management

A server implementing HTTP 1.1 allows a maximum of two simultaneous connections to a given client at the same time. Part of the reason for this is to ensure that no one client can overwhelm a server with so many requests that other clients don't get responses. Web browsers following this standard will also only allow two connections to a given domain, which is why pages with lots of external resources (JavaScript files, stylesheets, images, etc.) take longer to finish loading.

If you're going to be implementing a Comet connection, keep in mind that this will be using up one of the two available connections to the server. This can significantly slow down interactivity when an Ajax application requires the use of both traditional Ajax techniques and a Comet connection. With only one free connection available, all Ajax traffic must wait for it to become free before sending a request and receiving a response. Particularly problematic is when one Ajax response takes a long time to be sent, backing up all of the Ajax traffic for the application.

The best solution to this problem is to use a specific subdomain for the Comet connection. For instance, if your web application runs off of www.mywebapplication.com, use comet.mywebapplication.com for your Comet connection. This ensures that both connections are still available to the web application from the main domain (subdomain connections don't count against the two-connection limit) while the Comet connection remains open.

NOTE

Remember, JavaScript can't access external domains, so a subdomain is your only choice to work within the HTTP 1.1 limit.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset