Skip to content
Hosting Operations8 min read

Cloudflare Setup Guide: 7 Performance Tweaks That Work

Speed up your Cloudflare-proxied site with cache tuning, compression rules, and edge optimization. Fix slow loads in under 20 minutes.

Written by Abdul AbrorTechnical Hosting Support Engineer
man in black and white checkered dress shirt using computer
On this page

TL;DR — Key takeaways

  • Enabling Brotli compression and Auto Minify together typically reduces transfer size by 40-60% for text assets without origin changes
  • Setting Cache Everything page rules for static paths cuts origin requests by 70-85% after the first visitor warms the edge cache
  • Argo Smart Routing reduces latency by 15-35% on average by selecting faster network paths between Cloudflare data centers and your origin
  • Tiered Cache with regional Upper Tier locations reduces origin bandwidth by consolidating cache misses from multiple edge data centers into single requests

Adding Cloudflare to your domain puts a global CDN between visitors and your origin server. But the default configuration leaves most performance gains on the table.

I've worked support tickets where customers expected instant speed improvements after switching nameservers, then got frustrated when Time to First Byte stayed high. The proxy is active, but without cache rules and compression enabled, every request still hits your origin at full latency. This guide walks through the tuning steps that actually move the needle, with realistic before-and-after expectations for each change.

Verify Your DNS Proxy Status First

Cloudflare's performance features only apply to proxied records. That's the orange cloud icon next to each DNS entry.

Log into the Cloudflare dashboard, open the DNS tab, and scan your A and CNAME records. Gray cloud means DNS-only mode—requests bypass Cloudflare entirely and go straight to your origin IP. Click the cloud to toggle it orange.

Root domain and www subdomain should always be proxied. Subdomains like mail.yourdomain.com or ftp.yourdomain.com usually stay gray because SMTP and FTP protocols don't work through the HTTP proxy. API subdomains can go either way depending on whether you want WAF protection and caching.

Enable Compression and Minification

Cloudflare compresses text responses at the edge before sending them to browsers. Two settings control this: Brotli and Auto Minify.

Go to Speed → Optimization. Enable Brotli if it's off. Brotli compresses 15-20% better than gzip for HTML, CSS, and JavaScript. Supported by all modern browsers; Cloudflare automatically falls back to gzip for old clients.

Turn on Auto Minify for JavaScript, CSS, and HTML. This strips whitespace and comments from text assets as they pass through the edge. Reduces transfer size by another 10-25% depending on how verbose your source files are.

Before: a 180 KB uncompressed JavaScript bundle. After Brotli: around 45 KB. After Brotli + minify: approximately 38 KB. The difference shows up immediately in browser DevTools Network tab as smaller transfer sizes.

Configure Cache Rules for Static Assets

Watch your Cache Hit Ratio in the Analytics tab after deploying rules. You want 80-90% cache hits within a day or two as the edge warms up. Below 70% means too much traffic is bypassing cache due to query strings, cookies, or HTTP methods.

  • /wp-content/uploads/* for WordPress media libraries
  • /static/* or /assets/* for most web frameworks
  • /_next/static/* for Next.js builds
  • /public/* for Ruby on Rails asset pipeline

Tune Cache Behavior with Origin Headers

Cloudflare reads Cache-Control, ETag, and Vary headers from your origin and uses them to decide what's cacheable. Misconfigured headers kill performance even when Page Rules say cache everything.

Set-Cookie in the response disables caching completely. If your app sets a session cookie on every request—even for static assets—Cloudflare won't cache anything. Move session handling to a separate subdomain or use a path prefix that doesn't serve static files.

Vary: * also breaks caching because it tells the CDN that every request might need a unique response. Common culprit: some frameworks add Vary: Cookie by default. Remove it for static asset routes.

What About Argo Smart Routing?

Argo is a paid add-on that routes traffic across Cloudflare's private backbone instead of the public internet. Cuts latency when the path between edge and origin crosses congested or poorly peered networks.

Enable it in Traffic → Argo. You'll see the biggest improvement if your origin sits in a region with limited peering—think a VPS in Mumbai serving traffic from Europe, or a US-East server hitting Australia. Latency improvements range from 15% to 35% depending on geography.

The cost is $5 per month plus $0.10 per gigabyte. For a site pushing 100 GB monthly, that's $15 total. Worth it if Time to First Byte is your bottleneck and you've already maximized cache hit ratio. Less useful if most requests are cache hits because Argo only optimizes the origin fetch.

Enable Tiered Cache to Reduce Origin Load

Standard Cloudflare caching works per data center. A cache miss in Singapore and a cache miss in Tokyo both hit your origin separately even if they request the same file seconds apart.

Tiered Cache adds an Upper Tier layer between edge data centers and your origin. A miss in Singapore checks the Upper Tier (usually a nearby regional hub) before going all the way to origin. If Tokyo already warmed that URL, Singapore gets it from Upper Tier instead of origin. Cuts origin requests by 60-80% after the first hour of traffic.

Turn it on in Caching → Tiered Cache. Choose Smart Tiered Cache Topology unless you have a specific reason to pick a regional Upper Tier manually. Data centers near your origin server should go direct; distant ones should route through Upper Tier.

Monitor this in Cache Analytics. Watch for an increase in Upper Tier hits and a corresponding drop in origin requests. The effect is most visible for moderately popular content—files that get requested often enough to stay warm in Upper Tier but not frequently enough to live in every edge data center.

Test and Measure the Actual Improvement

Perceived speed improvements don't always match actual performance gains. Test methodically.

Use WebPageTest with multiple test locations. Run one test with Cloudflare enabled (normal DNS resolution). Then override DNS to point directly at your origin IP and run again. Compare Time to First Byte, Start Render, and Fully Loaded times.

Check Cloudflare Analytics daily for the first week. Cache Hit Ratio should climb above 80%. Bandwidth saved shows how much traffic never reached your origin. If bandwidth saved is under 50%, you're either not caching enough or your traffic pattern doesn't fit CDN caching well.

Edge response time in Analytics shows how fast Cloudflare answers requests from cache. Should be under 50ms globally. Origin response time shows how long your server takes to generate uncached responses. That number doesn't change with Cloudflare—it's your server's baseline. Focus tuning efforts on increasing cache hits so fewer requests see that origin delay.

Rollback Plan for Breaking Changes

Aggressive caching can break dynamic sites. Always keep a rollback path ready.

If you cache too much and users see stale content or broken logins, go to Page Rules and disable the problematic rule immediately. Changes propagate to all edge servers within 60 seconds. For faster rollback, switch the DNS record to gray cloud (DNS-only mode) to bypass Cloudflare entirely while you diagnose.

Before enabling Cache Everything on a new path, test in a private browser window to confirm session cookies and personalized content still work. Check one endpoint at a time rather than applying broad wildcards upfront. A rule matching /api/* might cache authentication tokens if you're not careful.

Common Pitfalls and How to Avoid Them

Setting Browser Cache TTL too high locks mistakes into visitors' browsers for days. Keep it at 4 hours for assets that might need emergency updates. Use versioned filenames (style.a3f2b9.css) if you want longer TTLs.

Caching HTML pages with Cache Everything works for purely static sites but breaks WordPress, e-commerce, and anything with user sessions. Cache images, scripts, and stylesheets aggressively; leave HTML at standard caching or use Cache Everything only on specific landing pages you control.

Forgetting to purge cache after deploying new code. When you push updated JavaScript or CSS, go to Caching → Configuration → Purge Cache and select Purge Everything. Selective purge by URL or tag is better but requires more setup. Without purging, visitors see old assets until Edge TTL expires.

Quick troubleshooting checklist

  • Verify DNS records are proxied (orange cloud) for performance features to apply
  • Enable Auto Minify for JS, CSS, and HTML under Speed → Optimization
  • Turn on Brotli compression in Speed → Optimization
  • Create Cache Everything page rule for static asset directories
  • Set Browser Cache TTL to at least 4 hours for static resources
  • Enable Argo Smart Routing if budget allows and origin is distant from users
  • Configure Tiered Cache topology with Upper Tier near your origin server
  • Test with and without Cloudflare using DNS override to measure actual improvement
  • Monitor Cache Hit Ratio in Analytics; target 85%+ for typical sites

FAQ

Why is my site still slow after adding Cloudflare?

Cloudflare only accelerates cacheable requests that hit the edge. If most traffic bypasses cache due to cookies, query strings, or POST requests, origin response time dominates. Check Cache Hit Ratio in Analytics. Below 70% means tuning cache rules or origin headers is needed. Dynamic content still travels to your server at origin latency.

Does Argo Smart Routing justify the cost for small sites?

Argo costs $5/month plus $0.10 per GB. Worth it if your origin server sits far from major user clusters and you see 200+ ms latency in Speed tests. A US-West origin serving Asia-Pacific traffic benefits most. Sites under 50 GB monthly transfer serving local audiences usually gain more from cache tuning first.

Can I enable Cache Everything for my entire domain safely?

No. Cache Everything applied globally will cache login pages, checkout flows, and personalized content, breaking sessions. Use Page Rules to target specific static paths like /assets/*, /images/*, or /wp-content/*. Always exclude admin paths, API endpoints, and any URL that varies per user.