TTFB estrange behavior

I have a site that is giving me an F if i run the test on non WWW domain
if i run the test on it gives me A.

Im runing wordpress and when you to to it redirects automatically to

here are the results.

NON-WWW domain

WWW domain

how can i fix that?

if possible, I have a vps with cpanel, 2gb ram, how can I fix it for all domains?

Any hints will be very appreciated.

That’s because of the additional time that it takes for the redirect - it completely blows your first byte time out of the water. It looks like you are already using a 301 redirect so it should be safe to ignore (assuming most users will land on the www version).

That said, the time for the redirect is a LOT longer than I would expect. Make sure you are doing the redirect directly in the .htaccess and not relying on wordpress to do it in the application layer.

hello pmeenan

I took your advice and now im doing the redirect directly, also created a .htaccess with the apropiate 301 redirect on my SKEL, that way all created cpanel account will redirect to nonwww to www as default.

is there any other way to improve this?
maybe changing the dns zone template?

I really want to know why non-www domain have longer TTFB.

thanks a lot

Unless you serve the same content from both domains there is no way to avoid the redirect (and you probably DON’T want to serve the same content because of SEO concerns). If you use a 301 redirect then the search engines will never display the non-www version of the domain and users who visit will only redirect once (the browser will cache the redirect).

I dont remember where but i was reading about making A records for non-ww and www to speeds up domain resolution

i don’t know if this is my case, is it?

No. That probably wouldn’t help anyway because of how DNS works (at best it would save a few milliseconds from the DNS lookup on one of the requests but it wouldn’t change the redirect).

For example, in Germany, Google will do a redirect from to If a redirect could be avoided, TRUST me, they would be the first to figure out a cool way to do it.

got it.

What can be causing that redirect lag that im having with non-www :confused:

Sorry i didnt mention my exact setup before…
im running a vps with 2gb ram, with a “reputable” provider.

cpanel/whms 11.30.3
Apache 2.20
nginx serving static content
php 5.3.8
PHP 5 Handler suPHP, Apache suEXEC on
MYSQL cache (I have mysql my.conf optimized says mysqltuner)
no IO wating
no CPU usage, just base process
90% free memory

my redirect rule #non-www to www 301 RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

what can be causing that redirection lag?

funny is that the same happen on a EC2 instance that i have also.
non-www getting F :confused:

I have the same 301 redirect to www.
Whats wrong?

does that means every new visit entering the non-www will have the little initial lag?

what will happen when google crawl my sites ?

You will pretty much always get an F for the first byte time check for any pages that have a redirect (301 or otherwise).

Yes, every new visit to the non-www page will have an initial lag so when you share links to the page you should share the version with the www.

Google crawls the domain based on links on the web. Is it common for links to go to your non-www domain or do they always go to the www version? The google bot should learn the 301 behavior pretty quickly and there is also a setting in webmaster tools to tell it which one of the domains is the one it should be paying attention to.

I have the www domain as prefered domain in the webmaster tools setting…

the main problem here is with the users. the tipical user always types non-www domains on therir browser and first time visits will suffer because of this…

I have the option to use non-www domains instead. but i really like to know how the redirect time can be improved or what can be done to fix that redirection lag.

The theoretical limit on how fast you can make the redirect is 150ms (on the DSL testing). To do that you need to “move” the server right next to your users and have it respond quickly. Right now it looks like your application layer is spending quite a bit of time processing the redirect.

This basically means:

  • Make sure the redirect is a .htaccess rule and is handled by the web server directly (it is being handled by Wordpress currently)
  • Make sure the redirect is cacheable (it is currently but when you move it to .htaccess you will have to verify)
  • Put your “non www” site on a CDN (this is actually incredibly difficult because you can not cname a top-level domain - it’s a lot easier to serve the site from non-www and have www on a CDN to do the redirect)

You might be able to get “fast enough” just by moving the redirect into .htaccess without having to worry about the CDN but a CDN is necessary for “as fast as possible”.

There is NO WAY to reduce the number of round trips (3) for the redirect so your only option is to make them as fast as possible.