Cloudflare Config Guide

DNS Record Types

RecordPurposeExampleProxy?
AIPv4 addressexample.com โ†’ 1.2.3.4Yes (orange cloud)
AAAAIPv6 addressexample.com โ†’ 2001:db8::1Yes
CNAMEAlias to another hostnamewww โ†’ example.comYes
MXMail exchange10 mail.example.comNo (DNS-only)
TXTVerification, SPF, DKIMv=spf1 include:... -allNo
NSNameservers (auto-set by CF)ken.ns.cloudflare.comNo

Cache Control

SettingBehaviorRecommended For
Cache Level: StandardCaches based on file extensionDefault setting
Cache Level: Cache EverythingCaches all content including HTMLFully static sites
Edge Cache TTL: 1 dayHow long CF keeps the cacheStatic assets (override origin headers)
Browser Cache TTL: 4 hoursCache-Control: max-age sent to browsersBalance freshness vs performance
Bypass Cache (Cookie)Don't cache if cookie presentWordPress, logged-in users

Cloudflare Workers

// Basic Worker โ€” intercept and modify response export default { async fetch(request, env, ctx) { const url = new URL(request.url); // A/B test routing if (url.pathname === '/') { const group = Math.random() < 0.5 ? 'a' : 'b'; url.pathname = `/variants/${group}`; return fetch(url.toString(), request); } // Add security headers to all responses const response = await fetch(request); const newHeaders = new Headers(response.headers); newHeaders.set('X-Frame-Options', 'DENY'); newHeaders.set('X-Content-Type-Options', 'nosniff'); newHeaders.set('Referrer-Policy', 'strict-origin-when-cross-origin'); return new Response(response.body, { status: response.status, headers: newHeaders }); } }; // KV storage const value = await env.MY_KV.get("key"); await env.MY_KV.put("key", "value", { expirationTtl: 3600 }); // wrangler.toml // name = "my-worker" // compatibility_date = "2024-01-01" // [[kv_namespaces]] // binding = "MY_KV" // id = "abc123"

SSL/TLS & Security Settings

SettingRecommendationNotes
SSL ModeFull (Strict)Validates origin cert; requires valid cert on origin
HSTSEnable with 6-month max-ageForces HTTPS; enable includeSubDomains carefully
Min TLS VersionTLS 1.2Drop TLS 1.0/1.1 for PCI compliance
Always Use HTTPSEnabled301 redirect HTTP โ†’ HTTPS
Bot Fight ModeEnabled (free)Blocks known bad bots
WAF Managed RulesEnable OWASP core rulesetBlocks SQLi, XSS, etc. (Pro+)