Reputation: 13109
Two related questions:
What are the maximum number of concurrent files that a web page is allowed to open (e.g., images, css files, etc)? I assume this value is different in different browsers (and maybe per file type). For example, I am pretty sure that javascript files can only be loaded one at a time (right?).
Is there a way I can use javascript to query this information?
Upvotes: 2
Views: 6927
Reputation: 1196
For anyone wandering into this nearly 15 years later, this is a restriction in http/1, but isn't in http/2 and http/3. You can read a good article why here, and a discussion on the differences here.
The TL;DR is that http/1 worked by creating separate TCP connections for separate requests. This could easily flood a webserver with tcp connections, and thus was capped. http/2 and http/3 don't work this way, and thus don't need the restriction.
http/2 and http/3 do allow for limits by the server (not the browser), but it's usually very high (100s).
Upvotes: 2
Reputation: 29892
For Internet Explorer see this MSDN article. Basically, unless the user has edited the registry or run a 'internet speedup' program, they are going to have a maximum of two connections if using IE7 or earlier. IE8 tries to be smart about it and can create up to 6 concurrent connections, depending on the server and the type of internet connection. In JavaScript, on IE8, you can query the property window.maxConnectionsPerServer.
For Firefox, the default is 2 for FF2 and earlier, and 6 for FF3. See Mozilla documentation. I'm not aware of anyway to retrieve this value from JavaScript in FF.
Most HTTP servers have little ability to restrict the number of connections from a single host, other than to ban the IP. In general, this isn't a good idea, as many users are behind a proxy or a NAT router, which would allow for multiple connections to come from the same IP address.
On the client side, you can artificially increase this amount by requesting resources from multiple domains. You can setup www1, www2, etc.. alias which all point to your same web server. Then mix up where the static content is being pulled from. This will incur a small overhead the first time due to extra DNS resolution.
Upvotes: 6
Reputation: 25677
Upvotes: 1
Reputation: 882586
There is nothing in HTTP that limits the number of sessions.
However, there are configuration items in FF for one, that specifically set how many total sessions and how many sessions to a single server are allowed. Other browsers may also have this feature.
In addition, a server can limit how many sessions come in totally and from each client IP address.
So the correct answer is:
1/ The number is sessions is limited to the minimum of that imposed by the client (browser) and server.
2/ Because of this, there's no reliable way to query it in JavaScript.
Upvotes: 1
Reputation: 700780
The limitiation is usually the web server. It's common that a web server only allows two concurrent downloads per user.
Active scripting engines like ASP.NET only executes one request at a time per user. Requests for static files are not handles by the scripting engine, so you can still get for example an image while getting an aspx file.
Pages often have content from different servers, like traffic measuring scripts and such. As the download limit is per server you can typically download two files at a time from each server.
As this is a server limitation, you can't find out anything about it using javascript.
Upvotes: 1
Reputation: 2613
One interesting way to get around the X connections per server limit is to map static resources like scripts and images to their own domains... img.foo.com or js.foo.com.
I have only read about this - not actually tried or tested. So please let me know if this doesn't work.
Upvotes: 5
Reputation: 116528
I know at least in Firefox, this value is configurable (network.http.max-connections
, network.http.max-connections-per-server
, and network.http.pipelining.maxrequests
), so I doubt you'll get a definitive answer on this one. The default is 4, however.
What are you attempting to accomplish?
Upvotes: 1