Following on from Max parallel http connections in a browser?, browsers can only have a few connections per host. I know this can be worked around using subdomains, but can I get around this by using different ports for the same host?
So would the following allow a browser to triple its connections (assuming something was listening on each port)?
www.example.com
www.example.com:8080
www.example.com:8081
Thanks
Yes, using a different port number will cause the browser to treat it as a different host, just like using a subdomain. I have not been able to find an authoritative source on how this should work, but the behavior is clearly demonstrable in current browsers. See Firebug and Chrome Dev tools screenshots below for loading a bunch of images.
The only different between the two is having all images point to the same port number:
<img src="http://localhost:8001/IMG_0277.JPG"><br>
....
Or having them point to a mixture of ports
<img src="http://localhost:8001/IMG_0277.JPG"><br>
<img src="http://localhost:8002/IMG_0278.JPG"><br>
<img src="http://localhost:8003/IMG_0279.JPG"><br>
....
来源:https://stackoverflow.com/questions/16283776/overcoming-max-persistent-connections-with-different-ports