Mobile app version of vmapp.org
Login or Join
Kristi941

: Google PageSpeed Insight: redirecting non-www to www does not use cache version 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.

@Kristi941

Posted in: #Apache #GooglePagespeed #PageSpeed #Wordpress

If I test my website with Google PageSpeed, I get a lower score if I test mydomain.com than if I test 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 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: www.tinywp.in/301-redirect-wordpress/
Now in PageSpeed I get same score with or without
HOWEVER, with webpagetest.org I still get a F for TTFB when I don't use www, and a A when I use 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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Kristi941

2 Comments

Sorted by latest first Latest Oldest Best

 

@Phylliss660

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: 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.

10% popularity Vote Up Vote Down


 

@Deb1703797

You're much better off doing a redirect from non-www to 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 ^(.*)$ www.example.com/ [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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme