Pages

Wednesday, December 1, 2010

To make your site even faster


To make your site even faster, serve certain content from different subdomains. For instance, on this site I serve (html, favicon, etc.) from www.askapache.com, (css, js, images, uploads, etc.) from static.askapache.com, and (flash, flv, swf, movies, mp3, etc.) from f.askapache.com. The reason this works is amazingly cool!
Easy Apache Speed Tips Articles
  • Turn On Compression
  • Add Future Expires Header
  • Add Cache-Control Headers
  • Turn Off ETags
  • Remove Last-Modified Header
  • Use Multiple SubDomains
A subdomain is the part of a domain that is appended to the beginning of the domain name, like a prefix. For example, my domain is “askapache.com,“ and 3 subdomains I am using are ”www.askapache.com,“ ”static.askapache.com,“ and ”f.askapache.com”.

Some handy in-page links to help you navigate:

  • Speed Benefits of Multiple Subdomains
  • Start using Subdomains

Speed Benefits of Multiple Subdomains

Basically when a visitor comes to http://www.askapache.com/htaccess/htaccess.html, they make a DNS request for each of my 3 subdomains [www/z/f].askapache.com to translate them into IP addresses. These hostname to IP address translations are then cached for that visitor, so no more DNS requests are needed. Because the first request was for http://www.askapache.com/htaccess/htaccess.html, the browser requests the .html document from the www server first. In the .html document the browser is told to also retrieve .css and .js files from my z server. In the .js file I load some flash which tells the browser to fetch the flash from my f server. So the users are able to see the content (.html) first, but thats not the only benefit to using these subdomains.

Subdomain Persistant Connections Benefits

The other benefit to using these subdomains is brilliant. Instead of a browser having to make 30 tcp connections to my www server to download everything, a browser is instead instructed to download 3 items from my www server, 22 items from my z server, and 5 items from my f server. So instead of waiting for 30 items from 1 source, it waits for 30 items from 3 different sources, drastically speeding up the transfer. By using multiple subdomains browsers are further able to maintain persistant connections with all 3 unique servers, making the site load incredibly faster.

Start using Subdomains

If you are an incredibly savvy and experienced web developer, no doubt you already have a DreamHost account, and so you already have the ability to add as many subdomains (for free) that you want. I think the limit per domain is 2500.

No comments:

Post a Comment