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