My website serves many images and I would like to parallelize the image requests by requesting via subdomain.
e.g. http://mydomain.com/image1.png becomes http://img[0-9].mydomain.com/image1.png
What I am searching for is a hash algorithm that will allow me to convert
"some-random-image-name.png" to a single digit range 0-9
so that I can load images via:
http://img0.mydomain.com/foo.png
http://img1.mydomain.com/foo.png
etc.
I can not use a random number because that would not be efficient. If the image loads from img1 I would like the next request for that image to also go to img1.
This would need to be fast as it will be called many times per page load.
Thank you for your ideas.
Adding node:
Why do this at all?
The browser will request only a limited number of requests from a single server. This is discussed in this post here:
Max parallel http connections in a browser?
In order to have a page with many static assets such as images load faster you add subdomains. Even if they are still coming from the same server.