Many Cloudflare users experience a strange issue when using the CDN service where the TTFB/Server response time is actually slower than without Cloudflare. You will find many discussions about this topic and we thought we would put together a quick guide on how to reduce the TTFB when using Cloudflare with your site.
We will assume that you have already addressed all serverside issues and achieve a sub 20-millisecond TTFB without Cloudflare. Response Time is a still an important factor in improving your site load time and especially SEO and TTFB is a ranking factor. There is some interesting debate around:
Cloudflare: ‘Stop worrying about Time To First Byte (TTFB)‘:
From the end user perspective, TTFB is almost useless. In this (real) example it’s actually negatively correlated with the download time: the worse the TTFB the better the download time.
Niel Patel also writes about the topic:
When you’re in the weeds of optimizing your site speed, play smart. Instead of trying hard to push down your document complete, start rendering, or fully loaded page load time metrics (all of which are important), focus on the highest-impact metric first: TTFB.
So TTFB does matter but you shouldn’t spend too much time worrying about it, instead, it should be part of improving the overall experience and load time.
Why is the TTFB & Server Response Time Slower with Cloudflare?
CloudFlare’s TTFB test server behaves a little differently. When it receives a request it sends the first letter of HTTP/1.1 200 OK and then waits for 10 seconds before sending the rest of the headers and page itself. By default, Cloudflare does not cache pages, only static resources. This adds extra call which would look like User > Cloudflare > Server, as Cloudflare isn’t caching HTML the request for the HTML would have to go through Cloudflare adding an extra request to the process.
How to reduce the Server Response & TTFB with Cloudflare Page Rules?
Reducing the Cloudflare server response time can be achieved by caching everything rather than just static resources. You can do this by using Cloudflare Page Rules to force caching of the entire page rather than static resources.
After deploying the new page rule ensure that you can log into your site and flush the Cloudflare cache if necessary.