2 reasons you should host all static content on a different domain

That is, to host all static content such as ready-made images, scripts, style sheets on a different domain rather than the primary one that hosts the page of the current URL. For example, if you intend to add static images to the web page located at http://www.example.com/page.html, you should not place the images on www.example.com, instead, put them somewhere else such as example-static.com or static.example.com.

The first reasoning for this is that browsers load web assets one by one or sequentially from a single host. They will not start requesting and downloading the next asset until they are finished with the previous one from the same domain. Therefore, doubling the hosts or domains can accelerate the downloading speed by about 100% because browsers can simultaneously download stuff from 2 different domains.

Another reasoning is that if cookie or session is enabled on your website, the browser would send the session cookie every time it makes a request to the domain, which sort of is useless because it’s static content — the server doesn’t need the cookie at all to serve static content such as images. It’s not only a waste of bandwidth but also a waste of communication time. To avoid this, serve all static content from a domain that is not cookie enabled. For instance, if you have set cookie with example.com, you can host all static content at static.example.com, however, if you have enabled cookie by *.example.com instead of just example.com, you will need to register a whole different domain to host the static content to steer clear of the useless overhead.

Not much for a small site, but this would be a major improvement regarding user experience for established, popular websites.

6 thoughts on “2 reasons you should host all static content on a different domain”

  1. Pingback: Add Absolute URLs of External JavaScript / CSS to Magento Header | Magento Go Review

Comments are closed.

Scroll to Top