Currently Available: Need a skilled Software Developer for your next project?
Categories
DNS

How to Find Out Whether Cloudflare or Your Origin Server Is Making Your Site Slow

When a visitor loads a slow page behind Cloudflare, any of four parts can hold up the request: the visitor's connection, Cloudflare's edge network, the route to your origin, or the origin server itself. Your origin is the server that hosts your site and builds responses whenever Cloudflare cannot serve them from cache.

To find the culprit, measure the same slow request in three places: your browser, Cloudflare's cache and request reports, and your origin server's logs. Your browser reports time to first byte (TTFB), which tracks how long the browser waits until the first byte of the response arrives. Because that figure bundles network travel and server work together, a high TTFB alone cannot tell you which side slowed things down.

Find the slow request first

A page can feel sluggish even when its HTML document loads quickly, because a single slow image, script, or API call can hold everything up. Open your browser's Network panel and find the exact URL that is dragging. Cloudflare also recommends pinning down the specific slow resources before you start digging into the server.

Once you have that URL, look at its timing breakdown in the Network panel. The browser splits each request into phases: DNS lookup (finding the server's address), connection setup, TLS negotiation (setting up encryption), waiting for the first byte, and downloading the content. Chrome's Network panel documentation walks through what each phase covers.

Watch where the browser spends most of its time. If the browser waits a long time for the first byte, something delayed the response before it even started arriving. If the browser spends most of its time downloading content, the slowdown comes from the transfer itself, such as the file size, the visitor's connection, or how fast the browser reads the data. Write down the URL, timestamp, status code, and response headers so you can match this exact request against your other measurements.

Measure the request and inspect its headers

Next, run curl from the command line against that exact slow URL to get a clean baseline. Use the same HTTP method and include the same cookies, authentication tokens, query parameters, and headers whenever you can, since any of those can change how Cloudflare caches the request or how your server answers it.

curl -sS -D - -o /dev/null \
  -w '\nDNS: %{time_namelookup}s\nTCP: %{time_connect}s\nTLS: %{time_appconnect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' \
  https://www.example.com/path

curl prints the response headers followed by cumulative timings for DNS lookup, TCP connection, TLS setup, first byte, and total time. Keep in mind that each number measures elapsed time from the start of the request rather than isolated application work. TTFB, for instance, includes the earlier connection phases plus the wait for the first byte of data.

Check the headers for cf-ray to confirm that Cloudflare handled the request. If you do not see cf-ray, check whether your hostname's DNS record is proxied, because a DNS-only record sends visitors straight to your origin. Note the CF-Cache-Status header as well, which tells you what Cloudflare did with that response.

Read cache status to trace the request path

CF-Cache-Status tells you whether Cloudflare had to contact your origin, though it does not label a response as fast or slow. Cloudflare lists the full set of meanings in its cache response headers documentation:

Header value What it tells you
HIT Cloudflare found the resource in cache. An ordinary cache hit does not require an origin fetch for that response.
MISS The response was eligible for caching but was absent, so Cloudflare fetched it from your origin.
DYNAMIC Cloudflare determined the request was not eligible for caching and sent it to your origin.
BYPASS Cloudflare skipped the cache because of the response or your configuration. Check your cache rules and origin headers such as Cache-Control.
EXPIRED The cached copy had expired, so Cloudflare fetched a fresh response from your origin.
REVALIDATED Cloudflare checked with your origin to confirm that a cached response was still current, which can add an origin round trip.
UPDATING Cloudflare served an expired resource while updating it in the background. The current request generally does not wait for that update.

If a slow response returns HIT, Cloudflare served it from cache and probably never contacted your origin. In that case, look at the visitor's connection to Cloudflare, any edge processing, and the response transfer. Keep in mind that Cloudflare Workers run code at the edge and can still slow down a request or make their own subrequests.

If the response returns MISS, DYNAMIC, BYPASS, or EXPIRED, Cloudflare went to your origin, so you need to check both the network path to the origin and the origin server itself. A REVALIDATED response also involves the origin because Cloudflare checked whether its cached copy was still fresh. You can also check the Age header to see how long a resource has sat in cache, though that number alone will not settle where the slowdown happened.

Compare Cloudflare’s origin timing with server timing

Cloudflare's Origin Analytics reports origin response times as percentiles, where each percentile marks the time that a given share of requests finished within. Filter for the same URL paths and time window as your slowdown, and look at the slowest requests rather than relying on averages. Cloudflare's Origin Analytics documentation explains how the metric is bounded.

Cloudflare starts that timer when it begins contacting your origin and stops it when your origin sends back the response headers. That means the number covers connection setup, network travel, and origin processing, while stopping before your origin finishes sending the response body. It is broader than pure application code, database queries, or CPU time.

Next, line up Origin Analytics against your own server-side records, such as request logs or application timing data, for the same paths and time window. If Cloudflare reports high origin response times while your server logs show fast processing, the bottleneck sits in the network or connection between Cloudflare and your origin. If both Cloudflare and your server report slow times for those requests, look at your server's load, application code, and data access. Before you compare the two numbers, verify where your server's timer starts and stops, because different servers record different parts of a request.

Use a direct-origin test as a comparison

When you know your origin's IP address and have permission to test it, you can compare a request through Cloudflare against one sent straight to your origin. This curl command connects to your origin IP while keeping the public hostname in the URL:

curl --connect-to www.example.com:443:ORIGIN_IP:443 \
  -sS -D - -o /dev/null \
  -w '\nDNS: %{time_namelookup}s\nTCP: %{time_connect}s\nTLS: %{time_appconnect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n' \
  https://www.example.com/path

Send both requests from the same machine using the same URL, HTTP method, and relevant headers. If your origin runs behind multiple servers, target the specific server that handles the affected request. Keep in mind that a direct test still travels over a different network path than Cloudflare's traffic, and your origin may apply different TLS settings or firewall rules to it.

If the direct request is slow, investigate your origin server and the network leading into it. If the direct request is fast while the proxied request drags, Cloudflare's edge processing or routing is the more likely culprit. Because the two requests follow different paths, treat this test as supporting evidence rather than final proof. Cloudflare outlines this comparison in its site troubleshooting guidance.

Combine the evidence before assigning a cause

Before you blame Cloudflare or your origin, line up your browser timings, cache status, Origin Analytics, and server measurements for the same URL and time window. Use this table to decide where to look next:

Evidence What to investigate next
Slow HIT with no matching origin slowdown Check browser timing, edge or Worker behavior, response transfer, and the route from the visitor to Cloudflare.
Slow origin-bound response and high Origin Analytics latency for the same path Compare Cloudflare's upstream time with your server's processing time and network measurements.
High browser TTFB but low Origin Analytics latency Check visitor-to-edge travel, edge processing, browser queueing, and verify that both measurements cover the same request.
Low TTFB but long total time Check content-download time, response size, and the visitor's connection.
Both direct and proxied requests are slow Compare your server's processing time with network timing, since a direct test alone cannot separate them.

Run your tests more than once instead of relying on a single request. If static assets load fast while a dynamic endpoint drags, focus on that endpoint and how Cloudflare caches it. If the slowdown only shows up during certain periods, compare those windows against your server load and Origin Analytics percentiles. Cloudflare's guidance for investigating uncached responses also recommends testing repeat requests and inspecting their response headers.

What I'm building

Delegate tasks. Get software.

Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.

Take a look at vroni.com

Email updates

Usually a new article and a few links I found interesting.

No spam. Unsubscribe with one click.

Leave a Reply

Your email address will not be published. Required fields are marked *