sellPerformance
public

CDN & Cache

Serve images, videos, and pages from a city near your user — not from a faraway server.

330+Cities in the network
~50msFrom 95% of internet users
348 TbpsNetwork capacity
0Extra hardware to buy
lightbulb

What is a CDN?

A CDN (Content Delivery Network) is a worldwide network of servers that keep copies of your website's content close to your visitors. Instead of every request travelling all the way to your one origin server, Cloudflare serves a cached copy from a nearby city — so pages load faster and your server does far less work.

store

Think of it like local convenience stores

Imagine one giant warehouse far away (your origin server). A CDN is like opening a convenience store on every street corner (edge nodes) stocked with the most popular items. You grab what you need from the corner store in seconds instead of driving to the warehouse.

The nearby servers are called edge nodes or edge locations. Cloudflare runs them in 330+ cities, putting content within about 50 milliseconds of 95% of the world's internet-connected population.

help

Why use Cloudflare's CDN?

Without a CDN, every visitor — no matter where they are — waits for content to travel to and from your single server. That is slow for distant users and risky when traffic spikes.

rocket_launch

Faster everywhere

Cached content is served from the city nearest each visitor, cutting the round-trip distance dramatically.

savings

Cheaper bandwidth

Every cache HIT is a request your origin server never sees, so you pay for less origin bandwidth and compute.

trending_up

Survives traffic spikes

When you go viral, Cloudflare absorbs the surge from cache instead of overwhelming your server.

toggle_on

On by default

Once your site is proxied (orange cloud), common static files are cached automatically — no code changes needed.

school

How caching works

When a request reaches an edge node, Cloudflare checks whether it already has a fresh copy. Cloudflare tells you the result in a response header called cf-cache-status.

check_circle

HIT

The edge had a fresh cached copy and served it instantly — the fastest, cheapest outcome.

cancel

MISS

No copy was cached, so Cloudflare fetched it from your origin and (if cacheable) stored it for next time.

history

EXPIRED

A copy existed but its time was up, so Cloudflare revalidated or re-fetched a fresh version from origin.

block

BYPASS / DYNAMIC

The content was skipped on purpose (BYPASS) or is considered dynamic and not eligible for caching by default.

timer

Edge TTL vs Browser TTL

Edge TTL is how long Cloudflare's servers keep a copy; Browser TTL is how long the visitor's browser keeps its own copy before re-asking.

layers

Tiered Cache

Edge nodes ask a nearby 'upper-tier' cache before bothering your origin, raising cache hit ratio and cutting origin traffic.

rocket_launch

How to control caching

You guide caching in two ways: with Cache-Control headers sent by your origin server, and with Cache Rules in the Cloudflare dashboard. Cache-Control is a standard HTTP header that tells caches who may store a response and for how long.

httpCache-Control header examples
# Cache a static asset publicly for 1 day (86400 seconds)
Cache-Control: public, max-age=86400

# Keep it 1 hour in browsers, but 1 day on Cloudflare's edge (s-maxage)
Cache-Control: public, max-age=3600, s-maxage=86400

# Never cache a private, per-user page
Cache-Control: private, no-store
  1. Proxy your site

    In DNS, make sure the record for your site shows an orange cloud. Caching only happens when traffic is proxied through Cloudflare.

  2. Create a Cache Rule

    Go to Caching > Cache Rules > Create rule. Match the files you want (e.g. URI path ends with .jpg, .css, .js) and set 'Eligible for cache' plus an Edge TTL.

  3. Verify with the response header

    Load your page twice and check the cf-cache-status header. The first load may be MISS; the second should be HIT.

    bash
    curl -sI https://example.com/logo.png | grep -i cf-cache-status
    # cf-cache-status: HIT
  4. Purge when you update

    After changing a cached file, go to Caching > Configuration > Purge Cache to force Cloudflare to fetch the fresh version.

target

When does caching help most?

image

Static assets

Images, CSS, JavaScript, fonts, and downloads rarely change and are perfect to cache aggressively.

newspaper

Content sites

Blogs, news, docs, and marketing pages are read far more often than they change.

groups

Global audiences

If visitors come from many countries, edge caching removes the long-distance penalty for everyone.

campaign

Launches & sales

Big traffic events are safer when cache absorbs the load instead of your origin server.

tips_and_updates

Tips & pricing

lock_clock

Cache static, bypass private

Cache images, CSS, and JS hard, but never cache logged-in or per-user pages — use Cache-Control: private, no-store for those so one user never sees another user's data.

  • Basic CDN and caching are included free on every Cloudflare plan.
  • Add a version string to filenames (style.v2.css) so updates bust the cache cleanly.
  • Turn on Tiered Cache to raise your hit ratio and protect a slow origin.
  • Cache Reserve (paid add-on) keeps content cached far longer using persistent storage.