A CDN (content delivery network) is an intermediary layer for websites, APIs, video, and file delivery. Cache hits avoid origin traffic; uncached requests can still use TLS termination, a WAF, rate limits, and routing optimization. Incorrect settings can cause stale content, mixed personal information, higher costs, or search crawling failures, so design and verification matter more than deployment alone.
A CDN is a distributed delivery and control layer between users and an origin
Its value is not copying every piece of data to the nearest server.Which requests may share a response, how stale it may be, and who may reach the origin are governed by rules so more traffic can be handled at locations close to users.
What is a CDN? Meaning and components
A CDN (content delivery network) receives HTTP requests between users and the origin server and delivers or forwards content through distributed locations. When public DNS points at a CDN, requests are routed to an appropriate location considering latency, network paths, failures, and capacity.
Shared caching is central to a CDN but not its only capability. Depending on product and contract, it may offer TLS termination, HTTP/2 and HTTP/3, compression, image transformation, WAF, DDoS protection, bot management, rate limits, edge code, logs, and signed URLs. It is useful to think of it as a distributed reverse-proxy platform that includes caching, not merely a cache server.
Origin server
The upstream source that produces authoritative content or application responses, such as a web server, load balancer, object store, or API.
Edge / POP
A distributed location receiving user traffic and potentially serving stored responses, TLS, compression, rules, and security processing.
Cache
A mechanism that stores previous HTTP responses and reuses them for eligible later requests. A browser cache and a CDN shared cache are distinct.
Reverse proxy
Receives requests in front of users and forwards them upstream. A CDN edge acts as a reverse proxy, but a single-location proxy is not necessarily a CDN.
CDNs, caches, DNS, and load balancers
| Term | Primary role | Relationship to a CDN |
|---|---|---|
| CDN | Delivers and forwards content through distributed locations, controlling routing, caching, and security | A delivery layer between users and origin |
| Cache | Reuses stored responses and computed results | A major CDN feature that also exists in browsers, applications, and databases |
| DNS | Resolves domain names to connection destinations | Can direct users to a CDN; DNS does not itself serve web content |
| Load balancer | Distributes requests among backends | Usually distributes origin-side applications, a different layer from CDN edge delivery |
| Web hosting | Provides web servers, storage, and runtimes | Can be the CDN origin; maintenance, backups, and capacity remain necessary |
| WAF | Detects and blocks malicious HTTP traffic | May be integrated with a CDN, but still requires rule design and false-positive handling |
How a CDN works: from request to cache hit or miss
Follow the request entry, cache-key creation, stored-response freshness check, origin fetch, and response storage. This is a generalized flow; intermediate layers such as regional or tiered caches differ by product.
Reach a CDN edge through DNS and routing
When a user accesses a URL, public-hostname DNS and provider routing direct the request to a POP. For HTTPS, TLS is established between the user and edge.
Build a cache key from the request
A CDN combines host and path with configured query strings, headers, cookies, methods, and other inputs. The same key means requests are treated as eligible for the same response.
HIT when the stored response is fresh
If a stored response for the key meets freshness conditions such as TTL, the edge returns it. Avoiding an origin round trip can reduce latency and upstream load.
MISS when absent; revalidate when expired
If no response is stored, fetch from an upper cache or origin. An expired response can be revalidated using ETag or Last-Modified, and a 304 Not Modified can reuse the stored body.
Store eligible responses and return them to users
Forward the origin status, headers, and body, and store the response for later if cacheability and TTL allow it. Check implementation and configuration for Set-Cookie, Authorization, status codes, and object sizes.
Example: 850 HITs out of 1,000 requests
These figures illustrate the mechanism. Dashboards differ by product in whether only cache-eligible requests form the denominator, how BYPASS and REVALIDATED are counted, and where tiered caches are measured.
850 ÷ 1,000 = 85%An example of the share of eligible requests served from a fresh edge cache. Compare HIT and MISS response times as well as the hit rate.
1 − (150 ÷ 1,000) = 85%A simple calculation assuming hits did not reach the origin. Tiered caches, request collapsing, and subrequests can make non-HIT counts differ from origin requests.
Cache keys, TTL, and Cache-Control are central to CDN design
More important than the number of locations are the cache key, which determines which requests may share a response, and TTL, which determines how long it may be reused. Ambiguity can fragment responses and lower the hit rate or mix responses intended for different users.
Include only values that actually change the response in the cache key
- Base:Host, path, and necessary query strings
- Consider including:Language, currency, tenant, image format, and other inputs that change the origin response
- Consider excluding:Unnecessary fragmentation from unique session IDs, tracking queries, or many User-Agent variants
- Authenticated pages:Do not share while ignoring Authorization or session cookies. Generally bypass shared caching or isolate strictly if sharing is justified
Key Cache-Control directives
| Directive | Primary meaning | Practical considerations |
|---|---|---|
max-age | Seconds for which the response is considered fresh | Affects browsers and shared caches; consider s-maxage for a different shared-cache lifetime |
s-maxage | Freshness lifetime for shared caches | Takes precedence over max-age in a CDN; check provider implementation and override rules |
public | Explicitly permits storage in shared caches | Before sharing authenticated responses, verify strictly that the content is truly identical for everyone |
private | Do not store in shared caches | Private caches such as browsers may store it; consider no-store for sensitive information |
no-cache | Requires revalidation before reuse | Does not prohibit storage. With ETag or Last-Modified, a 304 can reuse the body |
no-store | Prohibits storage | Consider for personal, payment, or sensitive responses; check whether CDN rules override it |
must-revalidate | Do not reuse a stale response without validation | Useful for important information that must not be served stale during origin failure, with an availability tradeoff |
stale-while-revalidate | Serve a stale response for a limited time during revalidation | Can reduce waiting, but evaluate product differences and staleness of critical information |
stale-if-error | Allow a stale response for a limited time on origin error | Can maintain access during failure; configure carefully for prices, stock, and legal information |
immutable | Indicates that content will not change while fresh | Combine with versioned URLs such as content-hashed CSS, JavaScript, and images |
Check RFC semantics separately from CDN product defaults. CDN cache rules, minimum TTL, or status-code TTL can override origin headers.
Example headers by use case
# Static file with content hash
Cache-Control: public, max-age=31536000, immutable
# Public HTML: five minutes in browsers, one hour in the shared CDN
Cache-Control: public, max-age=300, s-maxage=3600
ETag: "page-v42"
# Authenticated page containing personal information
Cache-Control: private, no-store
These examples are starting points. Test update requirements, provider rules, browser caching, revalidation, and permitted staleness.
Also understand CDN-Cache-Control and Cache-Status
RFC 9213 defines the concept of directives for particular shared caches such as CDNs, separately from general Cache-Control, and the CDN-Cache-Control header. It is useful when browser and CDN TTLs differ, but check provider support and precedence over proprietary headers.
RFC 9211's Cache-Status header reports how a cache handled a request in a standardized format. Not every CDN always emits it, so also use provider-specific headers such as Age、Via、CF-Cache-Status、X-Cache and logs.
Five CDN benefits
Benefits involve more than nearby servers: skipping origin work on hits, optimizing connections and compression at the edge, and distributing spikes combine to create an effect.
Can speed display and downloads
Serving from an edge near users and avoiding origin round trips can reduce waits for images, CSS, JavaScript, public HTML, and video.
Can reduce origin CPU, bandwidth, and connections
Reusing the same response at the edge can reduce requests and transfer to web servers, storage, APIs, and databases.
Can absorb traffic spikes
Distributed locations can handle concentrated requests for the same content after news coverage, campaigns, video releases, or software distribution.
Can serve some public content during failure
A public GET configured to allow stale responses may return stored content while the origin is temporarily unavailable. This is not complete disaster protection.
Can control attacks before they reach the origin
Apply WAF, DDoS protection, bot management, rate limits, and TLS termination at the edge and narrow origin exposure.
Benefits are concentrated on cacheable hits
Cold caches, personalized APIs, POSTs, writes, authentication, and database processing depend on the origin. Upstream performance, redundancy, and monitoring remain necessary.
CDN drawbacks and deployment considerations
A CDN adds another layer of paths and state. Even if delivery is faster, updates, failures, and security can become harder to diagnose, so do not consider benefits alone.
Stale information can remain
TTL and browser, edge, and regional caches can overlap, leaving old HTML or images after updates. Design versioned URLs, revalidation, and targeted purges.
Personal information can be mixed
A shared cache that ignores session, tenant, Authorization, or Cookie can cause severe data exposure. Generally bypass authenticated pages and test with separate users.
Misses add a hop
The user→CDN→origin path can make uncached traffic slower due to edge processing or connections. Measure dynamic APIs.
Costs can be hard to predict
Billing may include transfer, requests, functions, WAF, logs, purges, and dedicated IPs. Attacks, hotlinks, or cache-busting queries can also increase costs.
More failure and configuration points
CDN outages, DNS, certificates, WAF false positives, configuration propagation, and global purges add failure modes. Plan bypass, rollback, and access control.
Terminology varies by product
Definitions of HIT, MISS, BYPASS, DYNAMIC, EXPIRED, STALE, and UPDATING differ. Check dashboard denominators and log specifications in official documentation.
Content suited to a CDN and traffic that should not use a shared cache
Rather than judging only by extension, classify content by whether users with the same key may receive the same response、how stale it may be、and whether it depends on authentication or personal information.
CDNs and SEO: no direct ranking boost
Simply using a CDN does not increase rankings. Better speed and availability may indirectly help user experience and crawl stability, but content quality, search intent, indexability, canonical URLs, HTTP status, internal links, and rendering must be correct.
Google Search Central describes a CDN as an intermediary between origin and users and does not treat CDN use as inherently problematic. However, a cold cache can send Googlebot's first fetch to the origin, so origin capacity matters during crawl spikes. Correct HTTP caching can make refetching more efficient and reduce delivery load.
SEO checks during CDN deployment or migration
- Status:Return 200 for normal pages, appropriate 301 or 308 redirects for moves, and 404 or 410 for nonexistent URLs
- Robots:Do not accidentally change robots.txt, noindex, or X-Robots-Tag through CDN rules or error pages
- Canonical:Use the public canonical URL rather than a CDN hostname and check Host headers and redirects
- Crawler blocking:Ensure WAF, bot protection, and rate limits do not mistakenly block Googlebot or major crawlers
- Error caching:Avoid long caching of temporary 5xx or 403 responses and check that stale errors disappear after recovery
- Rendering:Ensure CSS, JavaScript, images, and fonts load on mobile without 403, CORS, or expired signature errors
- Speed:Measure cold caches, HTML, the LCP image, third-party scripts, and origin responses as well as hits
CDN security: consider origin protection and cache boundaries as well as a WAF
A CDN can intercept attacks before they reach the origin, but deployment alone does not make a system secure. Direct access to the origin can bypass a WAF or rate limits.
Use HTTPS from user to edge and edge to origin
Protect the origin side as well as the viewer side with TLS, and check certificate names, SNI, Host headers, redirects, and TLS versions.
Restrict direct origin access
Use supported mechanisms such as OAC, signed requests, mTLS, authenticated custom headers, firewall allowlists, or private networks to close non-CDN paths.
Design signatures and expiration for private content
Check signed URLs and cookies, permission revocation, cache keys, range requests, and resumable downloads together to limit the impact of leaked URLs.
Test cache poisoning and deception
Consider attacks that exploit headers outside the key or differing path interpretation to share harmful responses, or make an authenticated page look like a static file so it is stored.
What CDN DDoS protection can and cannot do
A CDN can improve resilience by absorbing traffic across a large network, blocking known attacks at the edge, and keeping cache hits away from the origin. Layer-7 attacks against expensive authenticated APIs or searches, cache busting, bots resembling legitimate users, and usage-based charges during attacks require separate measures.
Seven steps to deploy a CDN safely
Do not cache every URL at once. Start with observable static assets, expand gradually, compare URL, body, headers, status, latency, origin requests, and cost before and after, and preserve a bypass or rollback path.
1. Classify URLs and data
Separate static assets, public HTML and APIs, authenticated pages, uploads, administration, and errors; record methods, queries, headers, cookies, personal data, update frequency, maximum size, and range support.
2. Define success measures and tolerances
Set p95 latency, origin requests and bytes, error rate, cost, acceptable staleness, and stale-on-error policy. Do not target hit rate alone.
3. Verify DNS, TLS, and origin connectivity on a test host
Check viewer and origin TLS, Host, SNI, IPv4 and IPv6, CNAME, CAA, redirects, and certificate renewal. Compare the same URLs and headers before production cutover.
4. Define cache policy by URL group
Specify cacheability, keys, TTL, stale and error caching, compression, and forwarded headers, cookies, and queries. Start with hashed assets.
5. Test security boundaries
Check that response bodies do not mix between users, tenants, languages, or currencies, private content does not remain after logout, and direct origin access is restricted.
6. Prepare release, purge, and rollback
Use content-hashed static URLs and switch HTML to new versions. Plan emergency purge targets, completion checks, rate limits, costs, and the resulting miss surge.
7. Release gradually and monitor edge and origin together
Start with selected hosts, paths, or traffic and compare requests, bytes, cache status, latency, 4xx and 5xx, TLS, WAF, origin load, and cost on the same timeline.
Post-deployment checks with curl, headers, and logs
A browser's apparent speed alone cannot distinguish browser caching, CDN caching, and origin processing. Fetch the same URL several times and compare response headers with CDN and origin logs.
Start with response headers
# Inspect headers only
curl -I https://example.com/assets/app.a1b2.css
# Request the same URL several times without cache busting
curl -sS -D - -o /dev/null https://example.com/article/
# Extract selected headers and status
curl -sS -D - -o /dev/null https://example.com/ \
| grep -Ei '^(HTTP/|age:|cache-control:|etag:|vary:|cache-status:|cf-cache-status:|x-cache:)'
Metrics to inspect
| Metric | What it shows | Considerations |
|---|---|---|
| Cache status | HIT, MISS, BYPASS, EXPIRED, STALE, REVALIDATED, and others | Names, denominators, and treatment of cache tiers vary by product |
Age | Approximate seconds since storage in a shared cache | May reset or disappear after revalidation, purge, eviction, or movement between tiers |
| Origin requests | Requests that actually reached upstream | May differ from edge non-HIT counts |
| Origin bytes | Data transferred from upstream to CDN | Account for large objects, ranges, compression, and cache tiers |
| p50, p95, and p99 latency | Identify slow users and misses hidden by averages | Break down by HIT or MISS, region, path, and status |
| 4xx and 5xx | WAF false positives, origin errors, and certificate or DNS problems | Check whether error responses are cached |
| Cost | Changes in transfer, requests, functions, WAF, and logs | Separate bot traffic, hotlinks, attacks, and cache busting |
Common problems and investigation order
Content is stale after an update
Check browser cache, edge Age and status, TTL and s-maxage, purge targets, upper caches, then the origin body.
Hit rate does not increase
Check cache eligibility, Set-Cookie, Authorization, query variation, Vary, minimum TTL, object eviction, and traffic volume.
Another user's content appears
Immediately bypass and purge the cache, then investigate keys, Cookie, Authorization, tenant, Vary, and URL normalization. Treat it as a serious incident.
502 or SSL error only through the CDN
Check the origin certificate name, SNI, Host header, TLS version, firewall, origin timeout, DNS resolution, and IPv6.
How to compare CDN services
A large location count or free tier alone is not enough. Compare the following against your regions, content, authentication, and operational capability.
Delivery regions and measured latency
Measure HIT and MISS, HTML and large files, in regions where users are concentrated. Do not choose by advertised location count alone.
Cache-rule expressiveness
Check whether path, status, headers, cookies, queries, TTL, stale behavior, purges, and tiered caches meet requirements.
Origin protection and private delivery
Check OAC equivalents, mTLS, private networks, signed URLs and cookies, key management, and revocation.
WAF, DDoS, and bot protection
Check included coverage, extra charges, rule limits, managed rules, rate limits, logs, and emergency contacts.
Logs, analysis, and export
Check export of cache status, origin latency, request IDs, WAF, region, and cost, along with retention and delay.
Pricing and support
Compare transfer, requests, purges, functions, logs, WAF, dedicated features, minimum contracts, attack-related billing, and support hours under the same traffic assumptions.
Frequently asked questions about CDNs
Are a CDN and a cache the same?
No. A cache stores and reuses responses; a CDN is a distributed delivery platform between users and the origin. A CDN can also provide TLS, a WAF, routing, and dynamic forwarding.
Will a CDN always make a website faster?
Not always. Hits avoid origin round trips, but cold caches, dynamic processing, overly fragmented keys, or expensive edge processing may yield little improvement. Measure before and after under the same conditions.
Can a CDN serve dynamic content or APIs?
Yes. Briefly cache shareable GET responses or forward through the CDN without caching to apply TLS, a WAF, and rate limits. Generally do not share responses containing authentication or personal data.
Does Cache-Control: no-cache prohibit storage?
No. No-cache requires revalidation before a stored response is reused; no-store prohibits storage. Also check for overrides by CDN rules.
Does a WordPress site need a CDN?
Not necessarily. It may help with overseas visitors, large images, traffic spikes, or origin load. For a small domestic site, image compression, removing unnecessary plugins, and improving servers or databases may be more effective first.
Does a CDN improve search rankings?
There is no direct ranking guarantee. Speed and availability improvements may help user experience or crawl stability, but content quality, indexing, canonical URLs, status, and rendering remain prerequisites.
Does a CDN completely prevent DDoS attacks?
No. A CDN is one defense layer; combine it with a WAF, rate limits, origin restriction, protection against expensive application operations, attack-cost monitoring, and emergency response.
What cache hit percentage is good?
There is no universal target. Static assets may readily achieve high rates, while lower rates can be normal for frequently updated HTML or personalized APIs. Evaluate origin offload, latency, errors, correctness, and cost together.
Why does an old page appear after an update?
A browser or CDN may still consider a stored response fresh. Use content-hashed static URLs, short TTLs or revalidation for HTML, and targeted purges for urgent updates.
Primary and official sources reviewed
We distinguish HTTP standards from product-specific CDN examples. Do not treat product defaults or status names as universal CDN specifications.
IETF and RFCs
Official AWS CloudFront documentation
Official Cloudflare documentation
Official Google Search Central resources
Design cache keys, freshness, and origin protection together
A CDN puts distributed edges between users and an origin, reuses cacheable responses, and forwards uncached traffic. Hits avoid origin round trips, while misses, revalidation, dynamic requests, and writes reach upstream.
For safe deployment, define cacheability, keys, TTL, versioning and purges, staleness, and authentication boundaries by content type. Monitor edge and origin requests, bytes, latency, status, and cost on the same timeline. Sustainable acceleration requires preventing shared personal data, stale critical information, origin bypass, and post-purge load spikes.
- First:Classify URLs and data as public, shareable, or personalized
- Configuration:Include only response-changing inputs in the cache key and choose TTL and update methods
- Security:Test direct origin access, authenticated pages, cache poisoning, and deception
- Operations:Track origin offload, p95 latency, errors, and cost as well as hit rate
Finite Field Editorial Team's update policyWe distinguish standards such as RFCs from provider-specific behavior. Rather than judging only location counts or pricing, we update practical guidance on post-launch updates, security, failure behavior, and cost.