About Skills Projects Blog Contact View my CV ↗ Español
Cloudflare at Full Power: The Complete Guide to Every Tool and When to Use It

Cloudflare at Full Power: The Complete Guide to Every Tool and When to Use It

DNS, CDN, WAF, Workers, R2, D1, Zero Trust and more: what each Cloudflare product does, when to use it, and how to get the most without overpaying.

By Omar Flores
Table of Contents

Cloudflare started as a CDN with free DNS and today looks more like an operating system for the internet: it decides how your traffic arrives, protects it, caches it, executes it, and stores it. The question is no longer “should I use Cloudflare?” but which Cloudflare pieces do I use for what, and which ones will I regret enabling?

This post is a complete map, tool by tool, with usage criteria, limits, traps, and a staged adoption plan. The rule for reading it: every section answers four questions:

  1. What it is and what problem it solves.
  2. When to use it and when not to.
  3. How to get the most out of it (configuration, CLI, API).
  4. What it costs or where the bill may surprise you.

Honest note: Cloudflare ships products every few weeks. Prices, limits, and names change. Everything below is correct at the time of writing, but verify numbers in the official docs before deciding. What does not change is the architectural judgment.

The mental model: five layers

flowchart TB
    subgraph NET["1. Network and names"]
        DNS["DNS"]
        REG["Registrar"]
        ANYCAST["Anycast network / CDN"]
    end
    subgraph SEC["2. Security"]
        WAF["WAF"]
        DDOS["DDoS"]
        BOT["Bot Management"]
        RL["Rate limiting"]
        TURN["Turnstile"]
    end
    subgraph PERF["3. Performance"]
        CACHE["Cache Rules"]
        ARGO["Argo / Tiered Cache"]
        IMG["Images"]
    end
    subgraph DEV["4. Developer platform"]
        WORKERS["Workers"]
        DATA["KV · R2 · D1 · DO · Queues"]
        AI["Workers AI · Vectorize · AI Gateway"]
    end
    subgraph CORP["5. Corporate network"]
        ZT["Zero Trust: Access · Gateway · WARP"]
        TUN["Tunnel"]
    end
    NET --> SEC --> PERF --> DEV --> CORP
  • Layer 1 is where you start: DNS, domain, and proxy.
  • Layer 2 protects what you expose.
  • Layer 3 speeds up and cheapens what you serve.
  • Layer 4 is where you run logic and store data.
  • Layer 5 is for your private network: office, laptops, servers.

Most people stop at layers 1 and 2. The real advantage is using 1→5 as one system.

1. Network and names

DNS

The founding product, and still free. Cloudflare is the authoritative server for your zone: you delegate your domain by changing nameservers at the registrar.

  • Proxied (orange cloud): traffic goes through Cloudflare. You gain CDN, WAF, DDoS protection, caching, and you hide the origin IP.
  • DNS only (grey cloud): resolution only. Useful for MX records, subdomains pointing to other providers, and anything that cannot pass through the proxy (for example, SMTP).
  • DNSSEC: sign it. It is free and prevents cache poisoning. Then publish the DS record at the registrar.
  • CNAME flattening: you can put a CNAME at the apex (example.com) even though the standard does not allow it there. Essential to point the apex at an external service.
  • Records via API/Terraform: if you manage several domains, use the dashboard to explore and automate the rest.
# Look up the zone through the API (DNS is just one example resource)
curl -s -X GET "https://api.cloudflare.com/client/v4/zones?name=example.com" \
  -H "Authorization: Bearer $CF_API_TOKEN" \
  -H "Content-Type: application/json" | jq '.result[0].id'

Maximum use: one domain, DNS at Cloudflare, DNSSEC on, and everything that can be proxied is proxied. Subdomains you do not control (external SaaS) stay grey with a CNAME.

Registrar

You can buy and renew domains from the Cloudflare dashboard. It charges close to the registry price (ICANN + registry), without the typical registrar margin, and enables DNSSEC and some settings automatically.

  • When yes: new domains or easy transfers; you want consolidation.
  • When no: if your domain lives at a registrar with features you use (domain marketplaces, regional support, invoices).
  • Detail: registrar and DNS are separate products. You can keep the domain at another registrar and the DNS at Cloudflare, and that is the normal setup.

Email Routing

Free email forwarding: create addresses ([email protected]) that forward to your Gmail, or use pattern rules.

  • Configure the MX records it shows you.
  • Use Email Workers if you want your own logic (filter, reply, store in R2).
  • It is not an outbound mail server: for transactional email use another provider (Resend, Postmark, SES) and set SPF, DKIM, and DMARC in your zone.

2. Security

DDoS

Layer 3, 4, and 7 protection included on every plan, with no switch to flip. It is the reason many domains already sit here even if they use nothing else.

SSL/TLS

  • Universal SSL covers yourdomain and *.yourdomain (one level). Certificates validate automatically if DNS is at Cloudflare.
  • Correct mode: Full (strict). Flexible is the classic trap: Cloudflare→origin over HTTP, origins that redirect to HTTPS in a loop, and a false sense of security.
  • If your origin has no valid certificate, use a Cloudflare Origin Certificate or a certificate from your CA.
  • HSTS only once everything works over HTTPS. Start with a short max-age.
  • Minimum TLS 1.2 (or 1.3 if your clients support it), HTTP/3 on, Always Use HTTPS.

WAF

Web application firewall. On the free plan you get managed rules and custom rules with count limits; paid plans expand rules, rate limiting, and analytics.

  • Managed rulesets: enable OWASP and Cloudflare Managed with Block only on what does not produce false positives. Always review in Log first.
  • Custom rules: expressions over URL, method, headers, country, ASN, JA3/JA4, bot score. Example: block POST without Content-Type, or require a specific path.
  • Rate limiting: the product that prevents the most incidents. Limit by IP+path, for example 30 req/min on /api/login.
  • Detail: the WAF does not replace input validation or authorization. If your API has an IDOR, the WAF will not see it.

Bot Management and Turnstile

  • Bot Management (paid) scores bots. Interesting if you face aggressive scraping or credential stuffing.
  • Turnstile is free and is the modern alternative to reCAPTCHA: an invisible or explicit widget plus server-side validation against /siteverify. Use it on public forms, login, and signup.
  • Detail: validate the token on the server and consume the nonce once. A valid token does not mean “legitimate user”, only “passed the challenge”.

Waiting Room

Queue pages for traffic spikes (launches, sales, exams). Paid plans. If a spike can take down your backend, this is cheaper than scaling too much.

3. Performance and caching

CDN and Cache Rules

The CDN is included with the proxy. What controls how much you gain is the cache configuration:

  • Respect origin headers: Cache-Control: public, s-maxage=3600 is your best friend.
  • Cache Rules (the modern replacement for Page Rules): rules by URL pattern, extension, header, or path. Examples:
    • All /_astro/* → cache 1 year, immutable.
    • /api/* → bypass.
    • HTML → short cache with revalidation.
  • Purge: by URL, by tag (Cache-Tag), or everything. Use tags to invalidate only what you need.
  • Detail: never cache authenticated responses. If a response depends on a cookie, either exclude it or use Vary correctly.

Tiered Cache and Argo Smart Routing

  • Tiered Cache: small PoPs ask the nearest large PoP instead of going to the origin. It usually improves hit ratio noticeably.
  • Argo Smart Routing (paid): picks the least congested network path instead of internet’s default route. Useful when the origin is far away.
  • Cache Reserve (paid): durable storage to extend TTL and reduce origin egress.

Priority order if you must choose: well-built cache rules first (free), then Tiered Cache, then Argo.

Rules: the engine behind everything

The rules engine has replaced Page Rules. The ones you will use most:

Rule What it does Example
Redirect Rule 301/302 redirects /old/* → /new/$1
Rewrite URL Changes path/query without redirecting /api/v1/* → /v1/*
Cache Rule Forces or denies caching Cache images for 1 year
Origin Rule Changes origin host/port Route to a different port
Transform Rule Adds/removes headers X-Robots-Tag: noindex on staging
Configuration Rule Per-route settings Disable rocket loader on /admin
Custom Error Your own error pages 502 → static page

Maximum use: use rules so the origin only receives traffic that matters. If a request can be answered with a redirect or a cache hit, it should never reach your server.

Images, Stream, Calls, Realtime

  • Images: resizing, automatic format (AVIF/WebP), variants by URL or Worker. Paid plans per stored/delivered image.
  • Stream: video encoding and player. A private alternative to YouTube.
  • Calls: managed WebRTC.
  • Realtime: WebSockets at scale.
  • Zaraz: server-side tag manager; moves analytics and pixels to the edge so the browser does not load them.

4. The developer platform: Workers and friends

This is where Cloudflare stops being a CDN and becomes a compute provider. Everything runs on Workers: V8 isolates (not classic containers), millisecond startup, billed by request and CPU time.

flowchart TB
    W["Worker<br/>edge logic"] --> KV["KV<br/>config / key-value cache"]
    W --> R2["R2<br/>objects, free egress"]
    W --> D1["D1<br/>distributed SQLite"]
    W --> DO["Durable Objects<br/>unique state and coordination"]
    W --> Q["Queues<br/>async work"]
    W --> HD["Hyperdrive<br/>pool to Postgres/MySQL"]
    W --> V["Vectorize<br/>vectors for RAG"]
    W --> AI["Workers AI<br/>edge models"]
    W --> AIG["AI Gateway<br/>LLM observability"]

Workers

  • What it is: JavaScript/TypeScript functions (or Python, Rust compiled to WASM, and other languages through workerd) running globally.
  • What it gives you: HTTP handler, cron triggers, queues, bindings to every service.
  • What it is NOT: a Linux server. No persistent filesystem, no long-running processes, CPU and memory limits. For heavy work, use Queues + Workers or Containers.
  • When yes: lightweight APIs, BFFs, response transformation, auth, webhooks, cron, edge SSR.
  • When no: sustained CPU loads (video transcoding, model training), long-lived in-memory state, legacy software that expects a full OS.

Basic CLI:

npm create cloudflare@latest my-worker   # scaffold (C3)
cd my-worker
npx wrangler dev                        # local with real workerd
npx wrangler deploy                     # to production
npx wrangler tail                      # live logs

A minimal handler:

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const url = new URL(request.url);
    if (url.pathname === "/api/hello") {
      return Response.json({ ok: true, edge: request.cf?.colo });
    }
    return new Response("Not found", { status: 404 });
  },
} satisfies ExportedHandler<Env>;

Detail: request.cf carries country, city, colo, ASN, TLS, and more. The colo field tells you which datacenter answered.

Static assets: Workers can serve complete static sites, and static asset requests do not consume your request quota the same way. It is the modern way to deploy static Astro/Next sites (Pages still exists and is valid).

KV

Global key-value store, eventually consistent, built for massive reads.

  • Use it for: configuration, feature flags, simple sessions, cached content, tokens.
  • Do not use it for: data that needs transactions, exact counters, or frequent writes (propagation can take up to 60 s).
  • Detail: value size is limited (25 MiB), and writes are expensive compared to reads.

R2

S3-compatible object storage with free egress. It is perhaps Cloudflare’s most tangible “blessing”: on AWS S3 you pay to get data out; here you do not.

  • Use it for: backups, images, artifacts, small data lakes, logs, heavy static files.
  • Client: any S3 SDK (boto3, aws-sdk) pointed at https://<account>.r2.cloudflarestorage.com; also a native binding from Workers.
  • Detail: you pay for storage and operations (Class A: writes/listings; Class B: reads). Egress is 0.
npx wrangler r2 bucket create my-bucket
npx wrangler r2 object put my-bucket/hello.txt --file=./hello.txt
npx wrangler r2 object get my-bucket/hello.txt

If you want the S3-compatible workflow in depth, see S3 and MinIO hands-on.

D1

SQLite-based SQL database, distributed by Cloudflare.

  • Use it for: small/medium apps, prototypes, relational data per tenant, lightweight SaaS backends.
  • Do not use it for: high-volume analytics, large OLTP workloads, or heavy joins. For that, Hyperdrive + Postgres.
  • Detail: there are limits on database size, query size, and concurrency; read the limits table. Use versioned migrations (wrangler d1 migrations).
npx wrangler d1 create my-db
npx wrangler d1 execute my-db --command "CREATE TABLE notes (id INTEGER PRIMARY KEY, body TEXT)"
npx wrangler d1 execute my-db --file=./seed.sql --remote

Durable Objects

Objects with unique, strongly consistent global state, one per key (for example, a chat room or a document).

  • Use them for: WebSockets, coordination, exact rate limiting, ordered queues, carts, games, collaboration.
  • Detail: each object is single-threaded; a bad key design means hotspots. Use alarms for deferred work. It is the edge equivalent of an actor.
  • Cost: billed by requests + storage duration; objects can hibernate so you do not pay while idle.

Queues

Message queue for decoupling: one Worker produces, another consumes with retries and dead-letter.

  • Use it for: processing uploads, sending emails, event fan-out, slow tasks that must not block the request.
  • Detail: define batches, retries, and DLQ from the start. A queue without a DLQ is silent data loss.

Workflows

Durable step orchestration (a state machine): each step runs once and state survives.

  • Use it for: approvals, onboarding, internal pipelines, any flow that waits hours or days.
  • Do not use it for: a simple request/response.

Hyperdrive

Accelerates connections to existing PostgreSQL/MySQL databases: pooling and connection caching from the edge.

  • Use it when you already have Postgres and want Workers in front without opening a thousand connections or paying handshake latency.
  • It is not a database: the database is still yours.

Vectorize, Workers AI, and AI Gateway

  • Vectorize: vector database for RAG and semantic search.
  • Workers AI: models (text, image, embeddings) running on the platform, billed by neurons/usage.
  • AI Gateway: proxy for OpenAI/Anthropic/Workers AI with logs, caching, rate limiting, and fallback between providers.

Maximum AI use: AI Gateway in front of all your providers (one control point and cache), Vectorize to retrieve context, Workers AI for cheap tasks (embeddings, classification), and a paid LLM only for what needs it. More detail in my posts on RAG without magic and AI costs.

Pages vs Workers

Aspect Cloudflare Pages Workers (with static assets)
Focus Static site + functions Full platform
Deploy Git integration / wrangler pages deploy wrangler deploy
2026 recommendation Existing projects New projects

This very blog is an Astro static site deployed with Wrangler to Cloudflare Pages, and I keep it that way because it works; a new project would use Workers.

5. Zero Trust and the corporate network

Cloudflare One is the suite for your private network: it replaces the classic VPN with identity.

flowchart LR
    DEV["Laptop<br/>WARP"] --> GW["Gateway<br/>DNS/HTTP filtering"]
    DEV --> ACC["Access<br/>who may enter"]
    ACC --> APP["Internal app"]
    TUN["cloudflared Tunnel"] --> APP
    APP --> DLP["DLP / CASB<br/>data and SaaS"]

Tunnel

Connects a private service to Cloudflare without opening ports or exposing a public IP. cloudflared runs near your app and establishes an outbound connection.

cloudflared tunnel login
cloudflared tunnel create my-tunnel
cloudflared tunnel route dns my-tunnel app.example.com
cloudflared tunnel run my-tunnel
  • Use it for: homelab, staging, internal panels, SSH, Grafana, databases (with Access in front).
  • Detail: never expose a tunnel without Access. An open tunnel is a published service.

Access

Per-application authentication/authorization: Google, GitHub, OIDC, SAML, one-time PIN. Policies by email, group, country, device.

  • Use it for: protecting dashboards, previews, internal APIs, SSH (with cloudflared).
  • Detail: combine Access with path rules: /admin/* requires the admins group; the rest requires authentication.
  • Price: the free plan covers up to 50 users, enough for many small companies.

Gateway and WARP

A device agent (WARP) plus policy (Gateway): DNS filtering, HTTP inspection, domain blocking, anti-malware, DLP, and control over what leaves your network.

  • Use it for: protecting corporate laptops, enforcing usage policies, blocking phishing.
  • Detail: start in Log mode, review false positives, then block. Same discipline as the WAF.

Email Security and CASB

  • Email Security (Area 1): filters phishing and BEC before it reaches the inbox.
  • CASB: visibility and control over unsanctioned SaaS apps.
  • Magic WAN / Magic Transit / Spectrum: network connectivity and L3/L4 protection for large enterprises. Enterprise.

6. Observability and operations

  • Dashboard analytics: traffic, cache hit ratio, threats, latency by country.
  • Logpush: exports logs (HTTP, firewall, Workers) to R2, S3, or a SIEM. Required for real forensics.
  • Workers Logs / wrangler tail: live logs with filters. In production, send logs to a central system; do not rely on tail.
  • Web Analytics: cookie-free analytics, free.
  • Radar and Observatory: public internet data and a free speed/DNS test. Useful to compare providers with data.

Maximum use: Logpush to R2 (cheap) + a small DuckDB/Polars pipeline to analyze. Pattern: raw logs in R2, aggregates in D1 or Postgres, dashboards where you live.

7. Management: API, Terraform, Wrangler

  • API: the whole dashboard is the documented API. Use a token with minimal scopes, never the global key.
  • Terraform provider cloudflare/cloudflare: zones, records, rules, workers, Access, etc. If you already use Terraform, this is mandatory to avoid hand-editing.
  • Wrangler: Workers/Pages/R2/D1/KV CLI.
  • Secrets: keep the token in your password manager or CI, not in the repo.
terraform {
  required_providers {
    cloudflare = { source = "cloudflare/cloudflare" }
  }
}

provider "cloudflare" {
  api_token = var.cloudflare_api_token
}

resource "cloudflare_record" "app" {
  zone_id = var.zone_id
  name    = "app"
  content = "my-origin.example.net"
  type    = "CNAME"
  proxied = true
}

8. What it costs: the decision guide

Need Plan/Product Note
DNS, CDN, SSL, DDoS, basic WAF Free Enough for 80% of sites
Advanced cache rules, expanded custom WAF Pro (~$20/mo per zone) The most cost-effective jump
SEO/analytics, support, slots Business (~$200/mo) Only if you truly need it
Workers API Free: daily quota; Paid: from ~$5/mo with millions of requests Request-based pricing changes the math
R2 Pay per GB and operations Egress $0
Zero Trust Free up to 50 users Then per user
Load balancing, Waiting Room, Images, Stream Paid per product Check whether you need them

How to avoid bill shock:

  1. Check request and CPU metrics before moving workloads to Workers.
  2. R2: watch Class A operations (listings) as well as storage.
  3. Durable Objects: duration is billed; use hibernation.
  4. D1: expensive queries are billed by rows read/written; index.
  5. Logpush: logs grow; set retention in R2.
  6. Set budget alerts in Workers Paid.

9. Three real architectures

A) Static blog/portfolio

  • Static Astro on Pages or Workers static assets.
  • DNS + CDN + WAF for free.
  • Images in R2 or Images.
  • Contact form: Worker + Turnstile + Email Routing.
  • Previews protected with Access.
  • Expected cost: $0 to a few dollars.

B) SaaS API at the edge

  • Worker as the API + D1 for small tenant data, or Hyperdrive + Postgres if you already have Postgres.
  • R2 for uploads.
  • Queues for emails and processing.
  • Durable Objects for rate limiting/rooms.
  • AI Gateway if you expose AI.
  • Access protects the admin; the public passes through WAF + rate limiting.

C) Corporate network

  • Tunnel for each internal service (no open ports).
  • Access as the identity door.
  • WARP + Gateway on laptops.
  • Email Security on email.
  • Logpush to R2 for auditing.

10. Staged adoption plan

  1. Week 1: DNS at Cloudflare, DNSSEC, proxy on, Full (strict), HTTPS enforced.
  2. Week 2: Cache Rules for static assets, managed WAF in Log mode, Email Routing.
  3. Month 1: Turnstile on forms, rate limiting on login/API, usage alerts.
  4. Month 2: first real Worker (webhook, cron, or BFF), KV/R2 as needed.
  5. Month 3: Zero Trust: Tunnel + Access for internal panels.
  6. Later: queues, D1, DO, Images/Stream, Terraform.

Do not enable everything on day one. Every product you turn on is one more thing to observe, pay for, and maintain.

11. Common mistakes and when NOT to use Cloudflare

  • Flexible SSL with an HTTPS origin: redirect loops and unencrypted traffic between Cloudflare and origin.
  • Caching dynamic HTML with cookies: users seeing other people’s data.
  • WAF in Block mode without reviewing logs: you block legitimate clients (APIs, mobile apps, good bots).
  • Tunnel without Access: a private service exposed to the world.
  • Forgotten domain auto-renewal: DNS does not save an expired domain.
  • A Worker with in-memory state assuming it persists: it does not.
  • Treating D1 like Postgres for analytics: it is not.

Do not use Cloudflare for: heavy model training, multi-hour batch jobs, large relational databases with complex analytics, or regulated workloads without reviewing regions and contracts. Cloudflare is excellent at the edge; not everything belongs at the edge.

Conclusion

Cloudflare is not a tool, it is a stack: DNS, security, cache, compute, data, private network, and observability. Getting the most out of it is not about enabling everything, but choosing by layer and by problem:

  • If the problem is reaching, DNS + proxy.
  • If it is protecting, WAF + rate limiting + Turnstile.
  • If it is speed and cost, cache rules + R2.
  • If it is your own logic, Workers + the right store.
  • If it is private networking, Tunnel + Access.

Start with layer 1, add layer 2, optimize layer 3, write at layer 4, and close with layer 5. And automate from day one: the API and Terraform are as much part of the platform as the dashboard.


If you want to keep going on the practical side, I have posts on K3s in full and Terraform for agile teams. And if you build something on Workers, let me know: I am always testing architectures at the edge.