views:

26

answers:

1

If we have a website with multiple images and videos, I've read that it's best to serve them from other domains so that the browser can simultaneously download a bunch of files, rather than waiting one by one for each file to be downloaded. For example, if we have a website http://example.com/, we might consider serving:

Videos from http://video.example.com/

Images from http://images.example.com/

etc.

Question: can we achieve the simultaneous downloading by tricking the browser into believing that the files are hosted there, or do they actually need to be at that location?

We can, for example, pretend to serve video from http://video.example.com/ when actually it's just a clever htaccess rewrite that ACTUALLY serves from http://example.com/video.php. In this case, the video is being served from the main domain but because we refer it as http://video.example.com/, it may think that it's another domain and thus load files simultaneously, rather than one by one.

Is this feasible?

+2  A: 

The browser can't tell where the file is actually being served so it doesn't matter.

The limitation is that browsers will only open a certain number of connections to each domain name. Different browsers have different limits. By using multiple domain names, you are increasing the number of connections the browser will use to download the content. You can use the program Visual Round Trip Analyzer to monitor how many connections the browser is using to download your page.

David