I was using pingdom to test the load speed on a site I'm working on and got different results for www vs non www. Wordpress automatically redirects to either www or non www depending on the settings.
For the site in question its set to use non www and when tested in pingdom it came back with a 1 second result. Shortly after that I tested the site again with pingdom now with www and it came back as 3 seconds.
I contacted my host (hostgator) cause I thought it might have been a weird dns issue and to be honest I'm not super clued up on dns related issues.
They told me that the redirect happens while wordpress is already loading so when I go to www it loads wordpress then redirects so it almost has to load the site twice. They suggested I use a standard htaccess redirect at the top of the htacess file.
After doing that I tested the site again with both versions and they both seem to load at around 1 second.
Now finally after all that my question is why does this happen? At what point does the wordpress default redirect kick in. Should I just by default add the redirect myself to the top of the htaccess file for all sites?
Basically just looking to find out more about how wordpress handles that redirect, if someone would perhaps link me to a codex page about it or a blog article that would be amazing.