I went for an interview yesterday where I was asked this question: \"How does ha
ID: 651140 • Letter: I
Question
I went for an interview yesterday where I was asked this question:
"How does having assets (images/videos) stored on a secondary domain (assets.example.com) reduce the load time of example.com?"
To that I answered that by having the code "call" those assets from a secondary website it reduces the traffic that is coming to the main domain and therefore only applying bandwidth to the main domain vs having to also serve bandwidth to request assets.
Is that correct?
Also, If i am correct, would you say it makes sense to start new websites with this in mind or do you prefer having it done after large traffic rates are achieved?
Explanation / Answer
I'm sorry, but your answer is incorrect. The main reason to use a sub domain would be to maximize parallel downloads, and you could take it a step further if said sub domain was cookie free. From Yahoo's Best Practices for Speeding Up Your Web Site:
Split Components Across Domains
Splitting components allows you to maximize parallel downloads. Make sure you're using not more than 2-4 domains because of the DNS lookup penalty. For example, you can host your HTML and dynamic content on www.example.org and split static components between static1.example.org and static2.example.org
and:
Use Cookie-free Domains for Components
When the browser makes a request for a static image and sends cookies together with the request, the server doesn't have any use for those cookies. So they only create network traffic for no good reason. You should make sure static components are requested with cookie-free requests. Create a subdomain and host all your static components there.
If your domain is www.example.org, you can host your static components on static.example.org. However, if you've already set cookies on the top-level domain example.org as opposed to www.example.org, then all the requests to static.example.org will include those cookies. In this case, you can buy a whole new domain, host your static components there, and keep this domain cookie-free. Yahoo! uses yimg.com, YouTube uses ytimg.com, Amazon uses images-amazon.com and so on.