For improve web page performance it is good idea to serve static content from a cookie less domain.
What is Cookies less domain?
Domains which don’t require some cookies from client to serve the request a call cookie less domain. For example if we need to serve static images there is no need to have any cookie or even session cookie.
Why not cookies?
Cookies normally are small amount of text stored on client. Cookies can be set for some domain or specific path in domain. If any cookie is set browser will send these with each and every request.
For example if a page has 20 images and 1 css the browser will send 22 request to server. If cookies have size of 2kb in total it will cause 22kb or network traffic for each page request. This will not only consume bandwidth it cause unnecessary delays for user.
Imagine if we can serve images from a separate domain or possibly a sub domain with no cookies, we can save significant bandwidth and time.
When setting cookies make sure that you set cookies for particular domain. For example set cookies for www.mydomain.com, and server images from images.mydomain.com. If you set cookies for a subdomain or separate domain, they will not be available on other domains. PHP function setcookie allows to set cookies for particular domain.

July 17th, 2009
administrator 
Posted in 
