CDN & Cache
Serve images, videos, and pages from a city near your user — not from a faraway server.
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.
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.
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.
Faster everywhere
Cached content is served from the city nearest each visitor, cutting the round-trip distance dramatically.
Cheaper bandwidth
Every cache HIT is a request your origin server never sees, so you pay for less origin bandwidth and compute.
Survives traffic spikes
When you go viral, Cloudflare absorbs the surge from cache instead of overwhelming your server.
On by default
Once your site is proxied (orange cloud), common static files are cached automatically — no code changes needed.
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.
HIT
The edge had a fresh cached copy and served it instantly — the fastest, cheapest outcome.
MISS
No copy was cached, so Cloudflare fetched it from your origin and (if cacheable) stored it for next time.
EXPIRED
A copy existed but its time was up, so Cloudflare revalidated or re-fetched a fresh version from origin.
BYPASS / DYNAMIC
The content was skipped on purpose (BYPASS) or is considered dynamic and not eligible for caching by default.
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.
Tiered Cache
Edge nodes ask a nearby 'upper-tier' cache before bothering your origin, raising cache hit ratio and cutting origin traffic.
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.
# 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-storeProxy your site
In DNS, make sure the record for your site shows an orange cloud. Caching only happens when traffic is proxied through Cloudflare.
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.
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.
curl -sI https://example.com/logo.png | grep -i cf-cache-status # cf-cache-status: HITPurge when you update
After changing a cached file, go to Caching > Configuration > Purge Cache to force Cloudflare to fetch the fresh version.
When does caching help most?
Static assets
Images, CSS, JavaScript, fonts, and downloads rarely change and are perfect to cache aggressively.
Content sites
Blogs, news, docs, and marketing pages are read far more often than they change.
Global audiences
If visitors come from many countries, edge caching removes the long-distance penalty for everyone.
Launches & sales
Big traffic events are safer when cache absorbs the load instead of your origin server.
Tips & pricing
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.
Related products
menu_bookOfficial docsopen_in_new