WWW and non-www completely different TTFB

Hi all,

So my site’s (CuriousMatrix.com) address is without WWW and everything points to https://CuriousMatrix.com.

While I am checking TTFB via https://tools.keycdn.com/performance I am getting completely different results when i type WWW and when I don’t.

See below difference:

Is this standard behavior or should I change something in my configuration?

Its worth noting that I set up Cloudflare manually and not using Bluehost automatic system, but I wanted to share what it states in Bluehost documentation:
" Limitations of the Cloudflare System: “Requests must currently be sent to www.$domain rather than $domain (which implies you might need to make some setup adjustments).”

However herby I think they (Bluehost) are referring to this limitation only if Cloudflare is enabled automatically by Bluehost and not manually as I did.

Appreciate any answer. Thank you.

In the www test, you didn’t specify http:// or https:// so I assume the test used HTTP. HTTP is redirected to HTTPS on Cloudflare, so the first byte is very fast as it doesn’t go to your origin, it’s just a redirect response from Cloudflare at a PoP near to the client.

For HTTPS, the request goes to Cloudflare then your origin (as the home page isn’t cached) which is why the TTFB is longer.

As you are redirecting www to the domain on your origin, that also slows things down a bit as it means two requests to your origin. You can instead do that redirect on Cloudflare at the same time as the HTTP->HTTPS redirect to save ~1s on your page load time (won’t improve TTFB, but will speed up the page).

You can see the timings of each redirect step here…
https://cf.sjr.org.uk/tools/check?91af0daf5e684c21a89f35d9d1a6bb71#connection-server-http

1 Like

Thank you very much for such a quick and detailed answer.

So you mean using redirects in Cloudflare with following configuration?

Yes, that will do it, but better to make sure any path is included in the forward so change the type from static to dynamic, use the expression…

concat("https://curiousmatrix.com", http.request.uri.path)

…and check the “Preserve query string” box.

Thank you so much sir. Very helpful.

Just one more question.
So now that I configured this rule directly in cloudflare I suppose I can remove any redirect rules I have in htaccess and also remove ReallySimple SSL plugin that I have in wordpress?

If you are sure your site will always be behind a proxied Cloudflare connection, then you can tidy your .htaccess from any rules that you instead use on Cloudflare. We do that as it helps keep our server configuration clean and simple, any redirect or rewrites we do on Cloudflare. If unsure, at least keep a backup, or keep the configuration in place for now (any redirects won’t be used as Cloudflare gets to do them first).

If the plugin provides SSL for your site, you need to keep it. Your server should retain a secure SSL configuration with a valid certificate so connections from Cloudflare to it are secured (using only Cloudflare’s “Full (strict)” SSL setting here).

1 Like

Great. Thank you very much for so many quick and detailed answers.

You’re the best.

Cheers.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.