What Is a CDN? How It Works and How to Use One

Published:

Your website loads quickly when you check it, but a visitor across the country waits for photos to appear. A CDN might help, yet the setup asks you to change DNS records and choose caching settings. That is an uncomfortable place to guess.

The worry is practical: you want faster pages without breaking email, checkout or access to paid downloads. This guide explains when a CDN can help, compares affordable options, and walks through connecting one while keeping public files fast and customer information private.

What Is a CDN?

A content delivery network, or CDN, is a group of servers that delivers website content from locations closer to visitors. It can store reusable copies of files so your main server does not have to send them for every visit. This can shorten delivery times and reduce work at your host. Cloudflare’s CDN explanation

Two terms help explain the arrangement:

  • Origin: The main server where your website’s files live and its pages are generated.
  • Edge server: A server in the CDN’s network that handles visitors’ requests and can deliver cached copies.
What Is A Cdn?: Cdn Basics: Origin And Edge Servers; Origin: Your Main Website Server; Stores Files And Generates Pages; Edges: Reusable Copies Near Visitors; You Keep Your Existing Hosting

You usually keep your existing hosting when adding a CDN.

For the examples throughout this guide, imagine you run a dog-friendly hiking blog with photo-rich trail guides and a paid downloadable trip planner.

How Does a CDN Work?

Requests reach a CDN through your domain’s DNS records or through separate addresses used for selected files. DNS records tell internet services where to find a domain.

The CDN routes a visitor to an appropriate edge location. Network conditions and availability affect that choice, so the physically closest server is not always the one used.

Visitor → CDN edge → Origin, when needed
             ↓
       Content returned
         to visitor
How Does A Cdn Work?: How A Cdn Handles A Website Request; Visitor Requests A File; Cdn Selects An Appropriate Edge; Routing Considers Network Conditions; Reusable Copy Available?; Yes: Deliver Cached Copy; No: Request From Origin; Store If

If the edge has a reusable copy, it can send that copy. Otherwise, it contacts the origin and may store the response for later requests.

Activating a CDN does not copy your entire website to every edge location. Files can enter the cache as people request them. On the hiking blog, a trail photo might be fetched on its first request and reused for later visitors.

Cache Hits, Misses and Expiration

A cache is a store of responses that can be reused. Three terms describe what happens:

  • Cache hit: The CDN finds a reusable stored response and serves it.
  • Cache miss: The needed copy is unavailable, so the CDN fetches it from the origin.
  • Cache TTL: The time to live determines how long a stored response stays fresh.

Suppose a public file has a one-hour TTL. During that freshness period, the cache can reuse it without checking the origin. Afterward, it may check whether the file changed or fetch a replacement. Expiration does not necessarily mean immediate deletion. Cloudflare’s explanation of freshness and retention

Cache Hits, Misses And Expiration: Cdn Cache Hits, Misses And Expiration; Hit: Reuse A Stored Response; Miss: Fetch From The Origin; The Needed Copy Is Unavailable; Ttl: How Long A Response Stays Fresh; 1-Hour Ttl; After Expiry: Revalidate Or Fetch

Caching can also happen in several places:

Cache locationWhat it does
Visitor’s browserSaves files on that person’s device for later use
CDNReuses eligible responses across visitors
Origin or hosting serverSaves files or generated pages to reduce work at your host

These layers can work together. They also explain why clearing one cache sometimes leaves an old image visible elsewhere.

Which Content Can a CDN Cache?

Start with public files that visitors can safely share:

  • Trail photographs and other images.
  • CSS files that control page styling.
  • JavaScript files that provide website features.
  • Fonts.

A CDN can also cache public web pages, including those generated by WordPress. It stores their HTML—the code that makes up a page—when suitable rules are in place. Passing through the CDN does not mean every response is cached. Cloudflare, for example, does not cache HTML by default. Cloudflare’s default cache behavior

Which Content Can A Cdn Cache?: Which Website Content Is Safe To Cache?; Can Every Visitor Safely Receive This Response?; Public Assets: Good Starting Point; Images; Css; Javascript; Fonts; Private Responses: Exclude From Shared Caching; Check

The useful question is: “Could every visitor safely receive this same response?”

Everyone can receive the same trail photo. They should not receive another customer’s order details or authorized planner download.

File type alone does not answer that question. A public sample PDF and a paid planner might both end in .pdf, but they need different treatment. Keep protected downloads outside shared public caching, and make sure your selling platform checks permission before delivering them.

Does Your Website Need a CDN?

A small website can benefit from a CDN. Visitor count alone is a poor way to decide.

I would consider one when:

  • Visitors are spread out: Your host is in one region, but readers arrive from several countries.
  • Pages reuse substantial files: The same photos, styling and scripts appear across many visits.
  • Traffic arrives in bursts: A popular link sends many people to the same content.
  • Your host offers a supported integration: You can activate useful delivery features without managing a separate setup.

For the hiking blog, public trail photos are a sensible starting point. If readers visit from several regions, serving those photos through a distributed network may help.

Does Your Website Need A Cdn?: Will A Cdn Help Your Website?; Strong Reasons To Test A Cdn; Visitors Across Regions; Reusable Public Files; Bursts Of Traffic; Find The Actual Bottleneck; Large Photo? Resize Or Compress; Slow Uncached Page? Fix

But match the fix to the problem. A CDN can reduce repeated delivery from your origin, while an uncached page with slow database queries can still be slow. An oversized photo also remains an oversized download unless you resize or compress it.

Distributed delivery can reduce pressure during traffic spikes, and some providers offer protection against attacks that flood a site with traffic. Those benefits depend on the service and configuration. Checkout still needs a working origin, and a CDN does not replace software updates, backups or secure accounts.

Before adding anything, ask your host whether CDN delivery is already included. If your website already loads well for its visitors, another service needs to offer a clear benefit.

Which CDN Should You Choose?

Check compatibility with your host or website platform first. Then compare coverage in your visitors’ regions, HTTPS support for encrypted connections, cache controls, customer support and ongoing cost.

There are two common connection methods:

  • Reverse proxy: Website requests reach the CDN first, and it forwards requests to your origin when needed.
  • Asset CDN: Selected files use separate CDN addresses, while the rest of the website can continue loading directly.

A platform-managed integration handles setup for you and may use either method. An asset CDN and a website security proxy do different jobs, so they can work together when there is a reason to use both.

OptionSuitable useDelivery coverageConnection methodCost basisMain tradeoff
Existing platform’s CDNA supported setup with little extra maintenanceLocations and included content depend on your host; confirm bothPlatform activation or supported integrationIncluded or an added chargeFewer controls may be available
Cloudflare FreeA compatible site needing a free website proxyGlobal network for proxied website traffic; caching depends on eligibilityStandard setup moves authoritative DNS to CloudflareFree core plan; optional services can cost extraDNS migration needs care, and the free plan has no contractual uptime guarantee
bunny.net asset deliveryPublic images and files while keeping existing DNS hostingGlobal network with selectable delivery regionsCDN file addresses, optionally using a custom subdomainData delivered by region, with a monthly minimumUsage affects the bill, and file addresses need integration
Which Cdn Should You Choose?: Reverse Proxy Or Asset Cdn?; Reverse Proxy; Visitor; Cdn First; Origin When Needed; Website Requests Pass Through The Cdn; Asset Cdn; Page From Origin; Selected Files From Cdn; A Managed Integration May Use Either Method

I use Cloudflare for CDN, DNS and security, so it is my default choice for a compatible self-hosted WordPress site. Its Free plan includes CDN delivery and Universal SSL certificates, which enable HTTPS connections between visitors and Cloudflare. It also includes unmetered protection against distributed denial-of-service attacks, commonly called DDoS attacks. Cloudflare’s plan comparison

Even so, I would use an adequate CDN already included with your platform before adding another account. Confirm whether activation adds a charge.

I would choose bunny.net asset delivery when the main need is delivering public files and keeping existing DNS hosting matters. Its regional, usage-based pricing makes your visitors’ locations relevant to the bill. bunny.net’s CDN pricing

For any metered service, estimate delivered data by region and check for request fees, origin transfer charges and optional extras. Lower origin bandwidth does not automatically reduce a flat-rate hosting bill.

How to Set up a CDN on Your Website

Use your platform’s supported integration when it meets your needs. The steps below cover the shared checks, with Cloudflare as the main example for a reverse-proxy setup and compact alternatives for asset delivery.

For the hiking blog, the initial goal is straightforward: deliver public photos and supporting files through the CDN while leaving checkout and protected planner downloads outside shared caching.

1. Save Your Settings and Measure the Starting Point

Back up your website and save the settings needed to restore its current delivery:

  • DNS: Current nameservers and a complete copy or export of DNS records.
  • Website delivery: Existing CDN, caching and asset-rewriting settings.
  • Account access: Working access to your host, domain registrar and chosen CDN.

Your registrar is the company where you registered the domain. It may be different from your host.

Next, measure representative pages. For the hiking blog, I would test a photo-heavy trail guide and the planner sales page.

Use a testing tool such as WebPageTest, which lets you measure loading from selected locations. Keep the test location, device and connection settings consistent. Save several results and note any existing errors.

Keep a public-page baseline alongside your speed tests. Start with five important URLs so you can check for unintended changes after switching delivery.

Lead Magnet Cover
FREE WORKSHEET

Free Website Change Workbook

Steal our tracker to check whether your old links work as planned after a site change.
Send My Free Tracker ❯
Instantly delivered to your inbox
Customer Avatar 1
Customer Avatar 2
Customer Avatar 3
Customer Avatar 4
Rated highly by 1,200+ users

Also write down how to undo the change. That might mean turning off a platform integration, disabling asset rewriting or switching website records back to DNS-only. Keep your existing hosting running throughout the transition.

2. Prepare the CDN Connection

Prepare the connection that matches your choice:

  • Managed integration: Confirm what it will change and how to disable it.
  • Asset CDN: Create a pull zone, which tells the CDN where to fetch files. Set its origin to your website’s HTTPS address and test one public photo through the supplied CDN hostname.
  • Cloudflare reverse proxy: Add your domain, choose the plan and review the imported DNS records.

For Cloudflare, compare the imported records against your saved copy. Automatic discovery can miss entries. Keep the website records: A and AAAA point to server addresses, while CNAME points to another hostname. Also keep MX records, which route incoming email, along with email authentication and service-verification records.

Set website records to DNS-only before replacing nameservers. This lets you move DNS hosting while website delivery continues directly.

Authoritative nameservers hold your domain’s official DNS records. Changing them tells the internet which service to ask for those records. DNS TTL controls how long lookup answers remain cached; it is separate from content-cache TTL.

If DNSSEC is enabled, remove the old DS verification records at your registrar and let cached copies expire before switching nameservers. DNSSEC verifies DNS answers, and leaving the old verification records can make the domain unreachable after the move.

Replace the registrar’s nameservers with those assigned by Cloudflare. Once the domain is active, re-enable DNSSEC through Cloudflare and update the DS record at your registrar as instructed. Cloudflare’s DNS migration guidance

3. Check HTTPS on Both Connections

A reverse-proxy CDN creates two connections that need protection:

Visitor ← HTTPS → CDN ← HTTPS → Origin

Check that certificates cover every website hostname you will switch, including www or relevant subdomains.

On Cloudflare, choose Full (strict). This requires an unexpired origin certificate that matches the hostname and comes from a publicly trusted certificate authority or Cloudflare Origin CA. If the origin does not meet those requirements, fix it before enabling the proxy. Cloudflare’s Full (strict) requirements

3. Check Https On Both Connections: A Cdn Needs Https On Both Connections; Visitor; Cdn; Origin; Https; Visitor-Facing Certificate Active; Valid Origin Certificate Matches Hostname; Plan For Direct Access During Rollback; Use A Browser-Trusted

I would retain a publicly trusted certificate at the origin because it also supports direct browser access during rollback. A Cloudflare Origin CA certificate is intended for the Cloudflare-to-origin connection and is not enough for ordinary direct browser access.

Wait until Cloudflare’s visitor-facing certificate shows as active. In a standard full DNS setup, Universal SSL can be provisioned while records remain DNS-only, so you can finish this check before switching traffic. Cloudflare’s certificate activation guidance

For asset delivery, open the test photo through its CDN hostname over HTTPS. If you use a custom address such as cdn.example.com, add the provider’s required DNS record and activate its certificate before updating website references.

4. Apply Safe Caching Settings

Start with public static assets and keep your origin’s caching instructions in force. Those instructions arrive in cache-control headers, which tell the CDN what it may store and for how long. Leave additional full-page caching disabled until basic delivery works.

For the hiking blog, that means caching public trail photos while excluding:

  • Login and administration pages.
  • Customer accounts and personalized responses.
  • Cart and checkout pages.
  • Protected planner downloads.

For Cloudflare, create a Cache Rule that matches the protected-download addresses used by your selling platform, then choose Bypass cache.

Use your platform’s supported exclusions for logged-in users and shopping sessions. A URL exclusion alone may miss personalized content served at other addresses.

4. Apply Safe Caching Settings: Safe Cdn Caching Rules For Your Website; Start With Public Static Files; Respect Origin Cache Instructions; Keep Private Responses Out; Use Url And Session Exclusions; Preserve Authorization Parameters; Match

Also preserve query parameters that change content or authorization. These are the parts after ? in an address. Removing a download token or treating different authorized requests as one cached file can break access controls.

Broad rules that force dynamic pages into the cache can disrupt login and checkout. Cloudflare’s guidance on dynamic-content caching problems

Choose freshness settings around how you publish:

  • Versioned assets: Longer lifetimes suit files whose addresses change whenever their contents change.
  • Files updated at the same address: Use shorter lifetimes or a reliable way to clear cached copies.
  • Browser and CDN caches: Set their lifetimes separately because they serve different purposes.

I would skip a blanket “cache everything” rule at this stage. Every private response you accidentally include becomes another problem to untangle.

5. Switch Delivery Through the CDN

Now enable the connection you prepared:

  • Managed integration: Activate CDN delivery through the platform’s supported control.
  • Cloudflare: Change the intended website A, AAAA or CNAME records from DNS-only to Proxied.
  • Asset CDN: Enable public-asset URL rewriting through one supported integration.

URL rewriting changes the file addresses used by your pages. For example, a public photo might load from cdn.example.com while the page itself keeps its existing address.

On WordPress, use one CDN integration for this job. Avoid having two plugins rewrite the same file addresses.

Keep mail-service hostnames and verification records DNS-only. Moving nameservers alone does not enable CDN delivery for website records that remain DNS-only.

Leave the origin available while cached DNS answers expire. Check the main domain, relevant subdomains and email delivery rather than waiting for one assumed “propagation time.”

6. Verify Caching, Performance and Essential Functions

First, confirm that a public file is reaching the CDN.

Open your browser’s developer tools and use the Network panel. Disable the browser’s local cache while the tools are open, load a public trail photo, and inspect its response headers.

For Cloudflare, look for CF-Cache-Status:

StatusMeaning
HITThe response came from Cloudflare’s cache
MISSAn eligible response was absent from the cache and fetched from the origin
DYNAMICThe request was not eligible for caching
BYPASSThe request was eligible, but the origin response prevented caching

These values describe cache decisions, so DYNAMIC on an ordinary HTML page is not automatically a fault. Cloudflare’s cache-status definitions

6. Verify Caching, Performance And Essential Functions: Verify Your Cdn Before Calling Setup Done; 1. Check Public-File Reuse; A Later Hit Supports Reuse; 2. Complete Essential Actions; Forms, Login, Purchase, Download; 3. Test Two Customer

Request the same public file again without adding a new query string. A later hit helps confirm reuse, though one miss does not prove a problem.

Then test what visitors need to do:

  • Browse images, navigation and styled pages.
  • Submit a contact or signup form.
  • Sign in and out.
  • Complete a test planner purchase.
  • Open an authorized download.
  • Use a second test customer account and confirm it cannot see the first customer’s order details.

Repeat your baseline performance tests using the same pages, locations and device settings. Compare several runs, including initial and cached requests. Keep the setup when essential functions work and it provides useful delivery gains.

Finally, review usage and billing after activation, especially for metered delivery and optional services.

How Do You Keep Cached Content up to Date?

Update the original content before clearing copies. Otherwise, the CDN can fetch the old version again.

For an ordinary correction:

  1. Publish the change at the origin.
  2. Clear the relevant WordPress or hosting cache if needed.
  3. Purge the affected CDN URLs.
  4. Check the published result while logged out.
How Do You Keep Cached Content Up To Date?: Update Website Content Before Purging Your Cdn; 1. Publish The Original Change; 2. Clear Host Cache If Needed; 3. Purge Affected Cdn Urls; Keep Unchanged Files Cached; 4. Check While Logged Out; Purging

A purge tells the CDN to discard a stored response. I prefer clearing specific URLs for routine edits so the CDN can keep serving unchanged files from its cache.

On one of my digital-product sites, I checked an edited page while signed in and assumed the update was finished. The logged-out version still showed the old wording. I now check the version a visitor receives before calling an edit done.

How Do You Keep Cached Content Up To Date?: Show Updated Images With Cache Busting; A Cdn Purge Does Not Clear Browser Copies; Woodland-Trail.webp; Give The Changed Image A New Address; Woodland-Trail-V2.Webp; Update The Page Reference Too; Check

Images need another consideration. A CDN purge cannot clear copies already saved in visitors’ browsers. Give a changed image a new address, such as replacing woodland-trail.webp with woodland-trail-v2.webp, and update the page to use it. This technique is called cache busting. MDN’s explanation of cache busting

On the hiking blog, check both the replacement photo and the trail guide that references it. A fresh file is little help if the page still asks for the old one.

How Do You Fix Common CDN Problems?

Start with the affected request and the most recent change. Changing several settings together makes the cause harder to find.

SymptomFirst checkCorrective action
Old text or images remainCheck the origin, host cache, CDN and browser in that orderPublish the correct original, clear affected upstream copies, then purge CDN URLs; version changed assets
Images or styling breakInspect the requested address, HTTPS certificate and response codeCorrect the CDN address or origin path, repair HTTPS, or disable the faulty rewriting integration
HTTPS error or redirect loopCheck both certificates and whether the origin and CDN disagree about HTTPSRepair the certificate or redirect configuration while retaining certificate validation
Forms, checkout or downloads failInspect cache rules and security blocks affecting the requestExclude the affected dynamic responses and adjust the specific blocking rule
Another customer’s information appearsCheck whether a private response was stored in a shared cacheStop shared caching for those responses, purge stored copies and verify with separate sessions
Expected cache hits never appearCheck eligibility, origin cache headers and whether the requested address keeps changingFix the specific cause; do not force private content into the cache
Website becomes unreachableSeparate DNS lookup failure, CDN-to-origin connection failure and origin failureRepair the failing layer or use the prepared delivery rollback

Repeated misses on an eligible static file deserve investigation. HTML passing through Cloudflare without being cached is expected under its default settings. Use CF-Cache-Status to guide the check. Cloudflare’s uncached-response diagnostics

How Do You Fix Common Cdn Problems?: Cdn Troubleshooting: Find The Failing Layer; Customer Data Exposed?; Stop Shared Caching, Purge, Test Separate Sessions; Unreachable Website; Separate Dns, Cdn Connection And Origin Failures; Https Errors Or

If you need to undo delivery, disable asset rewriting or bypass the proxy only after confirming the origin works directly with browser-trusted HTTPS. Check that the origin firewall permits direct traffic too.

A Cloudflare proxy bypass leaves Cloudflare hosting your DNS. Restoring old nameservers is a separate DNS rollback, which needs matching records and compatible DNSSEC settings. Reach for the smaller delivery change first when that is enough to restore service.

What Next?

Check whether your host already includes a CDN, then save a baseline test for one important page. That gives you a clear starting point before changing delivery.

Use the social buttons to share this guide when a website-speed discussion reaches the DNS-and-caching stage.

Which part of adding a CDN feels least clear on your website? Leave your answer, along with any other questions, in the comments.

Share this post with your friends & followers:
Abhishek is a data scientist by day & an online entrepreneur by night. He is known for his ability to simplify complex concepts and make them accessible to a wider audience. He started Passive Book to share his insights and experiences on how to effectively build an online business, which has quickly become a go-to resource for anyone looking to bootstrap an online business from scratch.

Leave a Comment

Build an Online Business 
Without Quitting Your Job

Join 10,000+ solopreneurs building six-figure online businesses from scratch with limited time & tight budgets using smart systems & AI automations.
Optin Form - Main

Free Bonus: Get access to our AI workflows & cheat sheets
Person sitting with laptop in home office environment with launching rocket, coffee mug, sleeping dog, bookshelf, and house plant illustrating work-from-home online business lifestyle. Decorative image.
Thank you for sharing

Follow Us On: