I’m testing my website to try and optimize it for speed using http://tools.pingdom.com. I’ve noticed that typing www. makes for sometimes significant speed changes. Why is this?
I’m testing my website to try and optimize it for speed using http://tools.pingdom.com .
Share
www.example.comandexample.comcan be completely different hosts with different websites, etc.; it is only by convention that they typically point at the same host. When you visit either one, the process goes like this (http://www.example.com/ used as example):www.example.comis. The resolver tells it that the IP is1.2.3.4.1.2.3.4on TCP port 80 (the default for HTTP), and asks for the path/for the hostwww.example.com(given in the Host header). The web server returns the document requested.Note that the DNS server could return different IP addresses for the different hostnames, or the web server could reply with a different page for each hostname. They typically do not to reduce user confusion, but it is possible.
It is likely that one is faster than the other because the IP address and resources for one are already cached; that is, they have been stored from a previous attempt to access the page, so the browser knows that it does not need to fetch them again.
It is for this and other reasons (e.g. search engine optimization, as g_thorn suggests) that it is often advisable to choose one canonical hostname to use, but there is no intrinsic advantage to either one.