My company hosts about 30 web sites all sharing the same code base and reusing many of the same images. Right now, the images for all of the sites are hosted on the one domain, and then every other site has to link to those images.
and on www.example2.com we have something like:
<img src="http://www.example.com/images/hello.jpg" />
Recently someone told me that I should be putting all of these shared/static images on a subdomain, but I don't see the advantages to this. I have heard that there might be a slight speed increase, but I've also heard that it can complicate things. Can someone elaborate?
A couple advantages to it:
- A separate domain prevents your domain's cookies from being sent for every image request, where they're not needed. Reduces the bandwidth overhead for each request.
- Most browsers will only make a certain number of HTTP requests at one time to a particular domain, so serving images and other static content off a second domain potentially doubles the number of HTTP requests at one time.
- You can conceivably use a different, lighter weight webserver like nginx/lighttpd to serve the static content.
- Managing it.
- Two DNS lookups instead of one.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki