VPS Tutorials
Free Cloudflare CDN Acceleration: Make Your Site Faster in 5 Minutes
A hands-on walkthrough for putting your site behind Cloudflare's free CDN: change your NS, pick the right cache rules, enable HTTP/2/3, add a simple WAF, and a few notes on the caching and origin-pull pitfalls I've hit along the way.
3 min read
I used the free Cloudflare plan to speed up my personal blog. Average latency from the Los Angeles node to mainland China dropped from 190ms to 120ms, the static asset hit rate is around 80%, and getting the bandwidth for free feels great — but caching, origin pulls, and the firewall all need to be configured correctly.
- Add the domain to Cloudflare: import your DNS records as prompted;
- Go to your domain registrar and change the NS: switch to the two nameservers Cloudflare gives you;
- Confirm the little cloud turns orange: only orange traffic goes through the CDN;
- Open
SSL/TLSand chooseFull (strict): this ensures end-to-end encryption; - Enable
HTTP/2,HTTP/3, and0-RTT: this improves concurrency and handshake speed; - In
Caching, setBrowser Cache TTLto 1h andEdge Cache TTLto 1d: the static asset hit rate will improve noticeably.
- Force caching for static assets:
*example.com/*.js|*.css|*.png|*.jpg→Cache Level: Cache Everything+Edge Cache TTL: a day - Don't cache the admin panel:
*example.com/wp-admin/*→Cache Level: Bypass, to avoid broken styles in the admin panel - Reduce sensitivity on API routes:
*example.com/api/*→ turn off caching + enableSecurity Level: High
- Rate limiting: block after more than 10 requests in 10 minutes with
/wp-login.php, which stops brute-force attacks - Country/ASN blocking: if your site only serves mainland China, just block high-risk overseas ASNs and save yourself the trouble
Run curl -I https://example.com/main.js locally and check the response headers:
CF-Cache-Status: HITmeans it was a hitAge: 12345shows how long it has been cached at the edge If it's always a MISS, it's most likely because the URL carries authentication parameters, or the server returnedCache-Control: no-store.
- The admin panel got cached too: I forgot to add a Bypass for the admin panel, so the login state was lost;
- The origin certificate expired: Full (strict) returns a 525 right away, so remember to get a valid certificate or use a Cloudflare Origin Cert;
- 301 redirect chains: HTTP→HTTPS→www is a three-hop chain that adds 100ms of latency; it's better to do it all in one redirect in Cloudflare;
- Over-compressed images: Polish/JPEG compression is on by default and can hurt clarity, so use it with care on e-commerce sites.
- Personal blogs/documentation sites: as long as you have plenty of static assets, the hit rate will be high;
- Small and medium e-commerce: works well with Page Rules to control which paths get cached;
- APIs/admin panels: don't cache business endpoints; lean on the firewall and rate limiting instead.
- The little cloud is orange
- SSL set to Full (strict)
- Cache Everything for static assets
- Bypass for admin/API
- WAF rules + rate limiting
- Confirm the hit rate with
curl -I