About Cloudflare url cache (TTFB)

Hello Cloudflare community,

Its my first topic here, so i’m sorry if i’m posting on wrong place.

Well, on my website i noticed time ago and now futher more, that when accessing it though Cloudflare proxy, it get higher TTFB sometimes… This does not happen when I access the site by the server IP directly.

For example, when i access on directly IP, for the first load i get around 300ms TTFB and next requests 150ms TTFB.

on the Cloudflare this happens too and many other times in spontaneous moments… also with higher TTFB (around 400ms).

At first I thought it was my server but my site is very optimized, and that doesn’t happen by accessing my IP directly…

Hi and you are difinitely at the right place! :slight_smile:

Testing to the IP directly does bypass two things:

  • DNS resolve
  • SSL resolve

Due to this, I also would expect a lower TTFB when testing against your IP directly. Also, it depends on what you want to achieve and how far/close you are to your origin server.

If you want to achieve, a fast global site, then Cloudflare is the way to go.
If you are very close to your origin server, your request to the IP very likely will be served faster than when access through Cloudflare, but this also means that if you are far away your request to your origins IP directly will be slower than through a CDN (if cached properly). I hope you understand this.

Yes, there would be away around this, so you are always faster, but with Cloudflare it’s ATM not possible since you can always be closer to your origin than to Cloudflare.

To test the real speed, you should run these commands:

  1. With Cloudflare:
curl -o /dev/null -H 'Cache-Control: no-cache' -s -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" https://[###DOMAIN###]
  1. bypassing Cloudflare:
curl -o /dev/null -H 'Cache-Control: no-cache' -s -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" https://[###DOMAIN###] --resolve '[###DOMAIN###]:[###PORT###]:[###IP###]'

Please replace:
[###DOMAIN###]: with the FQDN you want to test against
[###PORT###]: with the Port you want to test against
[###IP###]: with the actual origin IP of you server

Then see & compare the speeds of using Cloudflare against not using it.

Cheers.

1 Like

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