0

If I test my website with Google PageSpeed, I get a lower score if I test mydomain.com than if I test www.mydomain.com.

In the first case, Google complains my server took too much time to respond.

I use page/database caching on the server to speed up the site and basically pretty much all the wordpress website is stored on disk or in RAM. So it's very fast when loading from www.domain.com.

the non-www version is a ServerAlias in my Apache vhost file.

Why is Google PageSpeed not resolving to the www version when I test the website without the www ?

UPDATE

Ok, I've made progress. It turns out that my redirection was poorly configured indeed. It was probably working in the browser due to the canonical link but the server redirection did not work as expected.

I fixed the problem by following advice here: https://www.tinywp.in/301-redirect-wordpress/

Now in PageSpeed I get same score with or without www.

HOWEVER, with webpagetest.org I still get a F for TTFB when I don't use www, and a A when I use www. So there is still something wrong here I believe:(

FIXED I ended up doing the redirection in vhost. The lower grade is actully C for TTFB now and is explained by the redirection when testing the non-www version. The www versino gets grade A.

  • 3
    Any reason not to set a redirection from non-www to www? – heytools Aug 12 '15 at 16:24
  • Heytools is correct, you really should choose one or the other, and then redirect to whichever you've chosen. Not doing so can lead to duplicate content issues, where the same page is available at the www and non-www URLs. – nathangiesbrecht Aug 12 '15 at 16:27
  • if you try to access mydomain.com it will redirect you to www.mydomain.com. But somehow when I use PageSpeed (or webpagetest.org as well actually) it does not redirect and it does not get the cached pages – Sam Aug 12 '15 at 16:29
  • I've also used <link rel="canonical" href="//www.mydomain.com/" /> in the html code – Sam Aug 12 '15 at 16:30
  • How are you redirecting, server side or using html/javascript? – heytools Aug 12 '15 at 16:33
3

You're much better off doing a redirect from non-www to www. There is no need for canonical and no need for Javascript.

If you have apache with mod_rewrite installed, then in the main apache configuration file, you can add these lines:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

Of course replace "example" with your domain name.

Just make sure when you use webpagetest.org to check your non-www version that it redirects to the www version. You'll notice that with the first entry in the waterfall chart being highlighted as a redirect.

Redirects increase the TTFB, because when the server returns status code 301 or 302, it doesn't count as a web page. That's why the non-www version will have a higher TTFB (provided you redirect the non-www version to the www version).

TTFB stands for Time To First Byte which means how long it takes before one byte of actual HTML data that users want is sent to the web browser.

  • ok thanks. I have not done the redirection like this because I believe the way it is described in the link I posted here is more suitable when using vhosts. But it amounts the same. So the redirection is the reason I get a lower grade for TTFB on webpagetest.org, thanks for the information. – Sam Aug 13 '15 at 6:45
1

There are many technical reasons for using www over no-www, the most obvious one is no-www's cookies are sent to all subdomains, which will slow down static content even if you use static. subdomain.

More details here: http://www.yes-www.org/why-use-www/

As for why your no-www is really slow, it depends on many factors, your sysadmin got to diagnose it.

But it shouldn't matter from a SEO point of view as your main site (www.) is fast, the no-www is just "another site" redirecting to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.