views:

154

answers:

7

I noticed that on the web some sites have subdomains dedicated to images or information on sub-domains such as i.domain.com. I was wondering what is the advantage of this? Is there a name for this type of "Method"? Where can I get more information on this? Thanks.

+2  A: 

m.cnn.com is handy for mobile devices. Saves typing.

S.Lott
+5  A: 

Parallel-izing image/script downloads.

Some browsers will only have 2 concurrent connections open to a given domain at a time. If you have 20 images/scripts to download you can only get 2 at a time x10. If you use different domains (subdomains) you can increase the amount of concurrent downloads.

As an example StackOverflow puts images under i.stackoverflow.com to help with speed.

EDIT

As noted by Richard (in a comment) that the HTTP spec strongly advises a 2 concurrent connection limit.

Chad Moran
Worth noting that the 2 concurrent connections is a should (i.e. strongly advised) limit from the HTTP RFC.
Richard
+3  A: 

‘i.’ is often used for images for the reason explained by Chad. There is a little bit more to it, in that having the images under ‘i.’ allows a few more requests to come from the main domain without the images interfering.

In particular, every time you include an external <script>(*), the browser has to block rendering of the rest of the page under the script until the script file has been fetched and executed. If there are twenty images above the script element, those will all be queued up already and may be fetched before the script element, causing a big delay in rendering the page.

With a different hostname (even within the same domain) for important resources like the scripts, image requests won't clog up the pipeline for more important stylesheet and script resources; instead they will happen in parallel.

Plus of course by using a different hostname for images and other large resources like video files, you can kick those off onto a second server in the future.

(*: unless you use <script defer>, but that's rarely used and not globally supported.)

bobince
+1  A: 

You can use a cookie-free subdomain for static content (images, scripts, stylesheets etc).

Static content doesn't require cookies, so sending/receiving them is simply a waste of bandwidth.

LukeH
An excellent optimization. +1
Randolpho
+3  A: 

In addition to having more simultaneous browser connections, static content (images, CSS, Javascript) is often delegated to a CDN, which requires a new subdomain.

Julien
And even without a CDN, it's much easier to host static, large content separately with a new subdomain.
bzlm
+1  A: 

It can also help manage acces to the content wich is on another sub-domain, as you can safely assume that's all content from i.yoursite.com can only be linked by www.yoursite.com

For exemple with apache you can put a single .htaccess with a few simple rules to define access rights to your images in the root of the sub-domain.

MarmouCorp
+1  A: 

There are several reasons for using a separate sub-domain for certain resources:

  • Parallel downloading   The HTTP specification limits the number of simultaneous connections to two connections:

    Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy.

    But although most browsers support more than two simultaneous connections per server, there is a limit and distributing the requests will allow more simultaneous connections overall.

  • Static content   As images, style sheets and scripts are mostly static content, they can be swapped to a different server that is specialized on serving static contents. Thus no unnecessary loaded modules for processing server-side languages are hindering the server to deliver the contents.

  • Cookie-free sub-domain   Cookies are helpful but could cause unnecessary traffic as they are sent with every request they are valid for. So it’s a good practice to restrict cookies just to the www. sub-domain.

See the Yahoo!’s Best Practices for Speeding Up Your Web Site for more helpful speed-up tips.

Gumbo