Skip to content
Docs

Troubleshooting a slow website

This guide helps you identify and resolve performance issues affecting your website. It starts with basic diagnostics and progresses to advanced troubleshooting techniques.

Before you start: Verify traffic goes through Cloudflare

Before troubleshooting performance, confirm that your traffic is actually going through Cloudflare. If requests bypass Cloudflare, the issue is not related to Cloudflare and this guide will not help.

Check for the cf-ray header

Every response served through Cloudflare includes a cf-ray header. Check for this header:

Terminal window
curl -s -D- -o /dev/null https://www.example.com | grep -i cf-ray

If you see a cf-ray header (for example, cf-ray: 8a1b2c3d4e5f6g7h-SJC), your traffic is going through Cloudflare. If not, check your DNS configuration.

Verify DNS is pointing to Cloudflare

Your domain must resolve to Cloudflare IP addresses for traffic to be proxied:

Terminal window
dig +short www.example.com

The returned IP addresses should be Cloudflare IPs. If they point directly to your origin server, your DNS records are not proxied.

To fix this:

  1. Go to the Cloudflare dashboard.
  2. Find the DNS record for the slow hostname.
  3. Ensure the Proxy status is set to Proxied (orange cloud icon).

Gather information about the slow requests

Performance issues are easier to solve when you can pinpoint exactly what is slow. Start by gathering the following information:

  1. Identify specific slow requests - Determine which URLs, assets, or API endpoints are slow.
  2. Measure the slowness - Quantify the delay (for example, "this image takes 5 seconds to load").
  3. Reproduce the issue - Confirm the slowness is consistent and not a one-time occurrence.

Step 1: Use Observatory to analyze performance

Observatory provides synthetic tests and real user monitoring (RUM) data to assess your website's performance.

RUM is particularly important as these metrics are captured from your actual visitors' browsers so it's an objective view of how they are experiencing your website, rather than lab data, which is typically more detailed (useful for debugging) but doesn't always correlate with the devices or connectivity real people have access to.

Run a speed test

  1. Go to the Cloudflare dashboard.

    Go to Observatory
  2. Select Observatory.

  3. Enter the URL you want to test and select Run test.

Understand the results

Observatory reports key metrics:

MetricWhat it measuresTarget
Largest Contentful Paint (LCP)Time until the largest visible element loadsUnder 2.5 seconds
First Contentful Paint (FCP)Time until the first content appearsUnder 1.8 seconds
Cumulative Layout Shift (CLS)Visual stability during page loadUnder 0.1
Time to First Byte (TTFB)Time until the first byte of response is receivedUnder 800 ms
Total Blocking Time (TBT)Time the main thread is blockedUnder 200 ms

Real User Monitoring reports similar metrics but you'll see Interaction to Next Paint (INP) in place of Total Blocking Time (TBT).

TBT only measures during page load but INP measures every interaction real visitors make with your website.

Based on Observatory results, enable relevant Speed optimizations:

  • Brotli compression - Compress responses for faster transfer
  • Early Hints - Preload critical resources
  • HTTP/2 and HTTP/3 - Use modern protocols with multiplexing, allowing multiple requests over a single connection instead of opening separate connections for each asset
  • Image optimization - Automatically optimize and resize images
  • Rocket Loader - Defer loading of JavaScript to improve paint times

Step 2: Identify slow resources

If Observatory and RUM data point to specific issues, use browser developer tools to investigate individual resources.

Use browser developer tools

  1. Open your browser's developer tools.
  2. Go to the Network tab.
  3. Reload the page and observe which requests take the longest.
  4. Sort by Time or Duration to identify the slowest assets.
  5. Note the specific URLs of slow resources.

Look for:

  • Large images or videos
  • Slow API calls
  • Third-party scripts
  • Render-blocking resources

Step 3: Analyze origin performance

If your website is slow, the issue may be at your origin server. Use Origin Analytics to understand how your origin is performing.

Check origin response times

In the Cloudflare dashboard:

  1. Go to Speed > Origin Analytics.
  2. Review the Origin Response Time metrics.
  3. Look for patterns in slow responses (specific paths, times of day, or geographic regions).

High origin response times indicate your origin server is struggling. Consider:

  • Upgrading your hosting plan
  • Optimizing database queries
  • Implementing server-side caching

Check for slow Workers

If your zone has Cloudflare Workers deployed, they execute on every matching request and add to the total response time. A slow Worker is a common cause of high TTFB.

To check if Workers are affecting performance:

  1. Go to Workers & Pages in the Cloudflare dashboard.
  2. Review which Workers are deployed on your zone.
  3. Check the Analytics for each Worker to see execution times.
  4. Temporarily disable Workers to isolate whether they are causing the slowness.

If a Worker is slow, review its code for:

  • Slow external API calls or fetch() requests
  • Inefficient loops or data processing
  • Missing await statements causing sequential instead of parallel execution

Step 4: Measure performance from the command line

For detailed timing metrics on specific requests, use command-line tools to measure performance.

Basic performance test

Terminal window
curl -w "\n\nDNS Lookup: %{time_namelookup}s\nTCP Connect: %{time_connect}s\nTLS Handshake: %{time_appconnect}s\nTime to First Byte: %{time_starttransfer}s\nTotal Time: %{time_total}s\n" -o /dev/null -s https://www.example.com/slow-asset.jpg

Example output (bash):

DNS Lookup: 0.025s
TCP Connect: 0.045s
TLS Handshake: 0.120s
Time to First Byte: 0.350s
Total Time: 1.250s

Understand the metrics

The curl timing breakdown shows the following:

MetricDescriptionHigh value indicates
DNS LookupTime to resolve the domain nameDNS issues or slow resolver
TCP ConnectTime to establish TCP connectionNetwork latency or server distance
TLS HandshakeTime to complete SSL/TLS negotiationCertificate chain issues or slow server
Time to First Byte (TTFB)Time until first response byteSlow origin processing
Total TimeComplete request durationLarge file size or slow transfer

Test from different locations

To test from different geographic locations, use online tools like:


Step 5: Investigate caching

Caching is one of the most effective ways to improve website performance. When content is cached, Cloudflare serves it directly from a data center close to your visitors, eliminating the round trip to your origin server. This can reduce response times from hundreds of milliseconds to just a few milliseconds.

Uncached content must travel from the visitor to Cloudflare, then to your origin server, and back again. Use Cache Analytics to understand your cache performance and identify opportunities to cache more content.

Check if assets are cached

Check the cache status of a specific asset:

Terminal window
curl -s -D- -o /dev/null https://www.example.com/asset.jpg | grep -i "cf-cache-status"

Possible values:

StatusMeaningAction
HITServed from Cloudflare cacheNo action needed
MISSNot in cache, fetched from originMay need cache rules
DYNAMICNot eligible for cachingCreate a cache rule if static
BYPASSCache intentionally bypassedReview cache rules
EXPIREDCached copy was staleIncrease Edge TTL
REVALIDATEDCloudflare confirmed content is currentIncrease Edge TTL

For a complete list, refer to Cloudflare cache responses.

Use Cache Analytics

  1. Go to the Cloudflare dashboard.

    Go to Overview
  2. Review the Cache Performance section.

  3. Filter by Cache status equals MISS or DYNAMIC to identify uncached content.

Investigate why static content is not cached

If static assets (images, CSS, JavaScript) show a cache status of DYNAMIC, BYPASS, or MISS, investigate the cause:

SymptomLikely causeSolution
DYNAMIC statusContent type not in default file extensionsCreate a Cache Rule to cache the content
DYNAMIC statusOrigin sends Cache-Control: private or no-storeCreate a Cache Rule to override origin cache control
BYPASS statusA Cache Rule is bypassing cacheReview your Cache Rules configuration
MISS on every requestResponse includes Set-Cookie headerConfigure your origin to not set cookies on static assets, or use a Cache Rule to ignore cookies
MISS with query stringsDifferent query strings create different cache entriesUse a custom cache key to ignore or normalize query strings

Cache additional static content

By default, Cloudflare only caches certain file extensions. To cache additional static content:

  1. Go to Caching > Cache Rules.
  2. Create a rule to cache specific content.
  3. Set appropriate Edge TTLs.

Use Cloudflare Trace to debug cache rules

If your cache rules are not applying as expected, use Cloudflare Trace to simulate a request and see exactly which rules match. Trace shows you how your Cloudflare configurations (including cache rules, page rules, and other settings) would affect a specific URL.

This is particularly useful when:

  • A cache rule should be caching content but the response shows DYNAMIC or BYPASS
  • You are unsure which rule is taking precedence
  • You want to test a "what-if" scenario before making changes

Step 6: Diagnose network issues

If curl shows high TCP Connect or TLS Handshake times, the issue may be network-related rather than application-related.

Test your Internet connection

Visit speed.cloudflare.com to test:

  • Download and upload speeds
  • Latency (ping)
  • Jitter
  • Packet loss

Poor results indicate issues with your local network or ISP.

Run MTR from your location to Cloudflare

MTR combines traceroute and ping to show latency and packet loss at each network hop.

Terminal window
mtr -rw www.example.com

Look for:

  • High latency at specific hops (indicates slow network segments)
  • Packet loss (indicates network congestion or issues)
  • Timeouts (may indicate firewalls or routing issues)

For more details, refer to How to read MTR.

Run MTR from your origin to Cloudflare

If you have access to your origin server, run MTR from the origin to a Cloudflare IP address to test the network path between your origin and Cloudflare.

Terminal window
mtr -rw 104.16.132.229

High latency or packet loss on this path affects all requests that miss the cache.


Step 7: Understand network routing

How requests are routed to Cloudflare data centers can significantly impact performance.

Identify which data center serves your requests

Add /cdn-cgi/trace to your domain to see which Cloudflare data center is serving your requests:

Terminal window
curl https://www.example.com/cdn-cgi/trace

The colo field shows the three-letter airport code of the serving data center (for example, colo=SJC for San Jose). You can find the full list of Cloudflare data centers and their codes on the Cloudflare status page.

Why routing matters

When a request reaches Cloudflare:

  1. The request is routed to a nearby Cloudflare data center based on anycast routing.
  2. If the content is cached, it is served immediately.
  3. If not cached, Cloudflare fetches from your origin server.

If your origin server is geographically distant from the Cloudflare data center serving your users, uncached requests will be slow.

Troubleshoot unexpected routing

If requests are being routed to a data center that seems far from the user, this may be due to Cloudflare's automated traffic engineering or a user’s ISP routing traffic.

While Cloudflare always strives to provide the best possible performance by serving traffic from the closest location, reliability is the top priority. In instances where performance and reliability are in conflict, Cloudflare's systems are designed to prioritize a stable connection over a local one.

For more details, refer to Cloudflare traffic not being sent to the geographically closest data center.

Common causes of unexpected routing:

SymptomExplanation
Requests route to a distant data centerCloudflare traffic engineering for reliability, or ISP routing decisions
Routing changes between requestsNormal behavior - routing adapts to network conditions or ISP load balancing
Consistent routing to a distant regionISP peering location or Cloudflare capacity management
High latency despite nearby data centerNetwork congestion on the path

Solutions for origin distance

Consider these solutions based on your needs:

SolutionDescriptionBest for
Improve cache hit ratioCache more content to reduce origin fetchesAll sites
Tiered CacheUse upper-tier data centers to reduce origin requestsSites with global traffic
Argo Smart RoutingRoute traffic over faster network pathsSites with slow origin connections
Move origin closerDeploy origin servers in multiple regionsLarge-scale applications

Enable Argo Smart Routing

Argo Smart Routing analyzes network conditions in real-time and routes traffic over the fastest paths, reducing latency by an average of 30%.

Argo Smart Routing is part of Smart Shield, which bundles multiple Cloudflare performance and reliability features.

To enable Argo Smart Routing:

  1. Go to the Cloudflare dashboard.
  2. Follow the Smart Shield setup guide to enable the feature.

Argo is particularly effective when:

  • Your origin is far from your users
  • Network congestion affects certain paths
  • You need consistent performance globally

For detailed information about how Argo Smart Routing works, refer to the Argo Smart Routing documentation.


Contact Support if the problem persists

If you have followed the steps above and the performance issue persists, contact Cloudflare Support for assistance.

When contacting Support, provide as much evidence as possible to help diagnose the issue:

  • HAR file - Generate a HAR file that captures the slow requests. This provides detailed timing information for every request.
  • Observatory results - Share screenshots or links to your Observatory test results.
  • RUM data - If you have Web Analytics enabled, share relevant metrics showing the performance issue.
  • curl output - Include the timing breakdown from curl --write-out for the slow assets.
  • MTR results - If you suspect network issues, include MTR output from your location to the affected domain.
  • Specific URLs - List the exact URLs that are slow, along with the expected and actual response times.

The more evidence you provide showing the slowness, the faster Support can identify and resolve the issue.