Cloudflare and first byte

I added Cloudflare to my Wordress blog and while it seems to be running fast and smooth, I now score a “C” for first byte and I have never seen this score below an “A”…I also have a very slow 2nd view time. Any suggestions, fixes, or experience with Cloudflare?

http://www.webpagetest.org/result/110713_1P_11P29/

Check your server specially your database server and web server. If i look on your result i see that the server take a long time to answer after the dns request. i guess it is the configuration of your database.

By definition cloudflare will add some first byte time since it needs to go back to your server and process the data but it should be minimal. My algorithm for calculating a first byte time grade doesn’t play nicely with something like cloudflare though so look at the before/after first byte times and compare those directly (doesn’t explain the one long time you had in a repeat view though).

The algorithm for first byte time looks at the socket connect time to get an estimate of the round trip time to a server and then it uses a multiple of that as the baseline and adds 100ms for each letter.

Since cloudflare has distributed edge nodes, they actually make your socket connect time a LOT faster than if the browser had to go back to the original server directly so the baseline is lowered. The actual request still needs to travel back to your server though so it can’t be any faster than it was before (and will usually be slightly slower). The effect that has is that it will lower the grade even if it is actually faster because the round trip time used for the baseline is faster.

Just wondering if this has ever been updated. We are seeing the same really slow time to first byte with cloudflare. What should be the typical margin of error? 100ms? We are sometimes seeing a 500ms+ difference which seems high.

My algorithm only comes into play for the grade (and yes, it has been updated). The timings are all (and have always been) accurate.

Make sure you are looking at the full TTFB (including DNS, socket connect and request) and not just the TTFB of the first request because with CDN’t there is usually a trade-off where you get a faster connect to the edge but the connection to the origin is hidden in the request time.

Oh, and there is no “margin of error” on the TTFB measurement. The measurement itself is accurate to sub-millisecond resolution.