# CDN service explained: what it does, free options and how to choose one

> How a CDN service speeds up a website, what it caches, which free and paid options exist, and how to choose a CDN in five checks. Plain answers, no sales pitch.

Source: https://comparehostingonline.com/guides/what-is-a-cdn/

## Short answer

A CDN keeps copies of your static files, such as images, CSS and scripts, on servers around the world and serves each visitor from a nearby one. It makes pages load faster for distant visitors and takes load off your host. Most sites benefit, and many hosts include one.

Last verified Nov 28, 2026 · [How we test](https://comparehostingonline.com/methodology/)

At a glance

-   **What is a CDN?** A content delivery network is a group of servers spread across many locations.
-   **How does a CDN work step by step?** Their browser asks for an image or script on your domain.
-   **What does a CDN cache?** By default, static files: images, CSS, JavaScript, fonts and downloads.

## What is a CDN?

A content delivery network is a group of servers spread across many locations. Instead of every visitor connecting to your one hosting server, the CDN answers from the server nearest to them, which shortens the distance data travels. Your own server, called the origin, is contacted only when the CDN does not have a fresh copy.

The distance matters because every round trip between a visitor and a server takes time, and time zones away adds up. A page needs many requests: HTML, stylesheets, scripts, fonts and images. Serving most of them from a nearby location removes a large share of that delay.

## How does a CDN work step by step?

1.  1
    
    **The visitor requests a file**
    
    Their browser asks for an image or script on your domain.
    
2.  2
    
    **The nearest edge answers**
    
    If it has a cached copy, it sends it at once.
    
3.  3
    
    **The origin is asked only if needed**
    
    On a cache miss, the edge fetches the file from your host and keeps a copy.
    
4.  4
    
    **Later visitors get the cached copy**
    
    Until it expires or you purge it.
    

## What does a CDN cache?

By default, static files: images, CSS, JavaScript, fonts and downloads. These rarely change, so they are safe to keep for days or weeks. Some CDNs can also cache whole HTML pages for visitors who are not logged in, which is how a busy WordPress site survives a traffic spike. Pages that depend on the user, such as carts, checkouts and account pages, must not be cached or must be cached per user.

You control caching with HTTP headers such as Cache-Control, which tell a CDN and browsers how long a file is valid. The MDN documentation on HTTP caching explains these headers in detail.

## What is the difference between a CDN and web hosting?

A CDN does not replace hosting. It sits in front of it. Some hosts bundle one; others expect you to add one such as Cloudflare, covered in [do you need Cloudflare?](https://comparehostingonline.com/guides/do-you-need-cloudflare/).

|  | Web hosting | CDN |
| --- | --- | --- |
| Stores your site files | Yes, the originals | Copies, temporarily |
| Runs your code and database | Yes | No |
| Where it sits | One or a few locations | Many locations worldwide |
| Main job | Run the site | Deliver files fast and absorb load |
| Can you use one without the other? | Yes | No, a CDN needs an origin |

## What are the benefits?

-   Speed for visitors far from your server, especially on image-heavy pages.
-   Less load and lower data transfer on your host; see [bandwidth, storage and data transfer](https://comparehostingonline.com/guides/bandwidth-vs-storage-vs-transfer/).
-   Resilience: many CDNs absorb traffic spikes and filter attacks, which overlaps with [DDoS protection](https://comparehostingonline.com/guides/what-is-ddos-protection/) and a [web application firewall](https://comparehostingonline.com/guides/what-is-a-web-application-firewall/).
-   Modern protocols such as HTTP/3 and compression handled for you; see [HTTP/3 and hosting](https://comparehostingonline.com/guides/what-is-http-3-and-hosting/).
-   Often a free tier for small sites.

## What are the downsides and risks?

-   Stale content: cached files can show old versions until you purge or they expire.
-   A misconfigured cache can leak personalised pages, a serious problem. Exclude logged-in and cart pages.
-   SSL settings must agree between the CDN and your origin, or you can create redirect loops; see [what an SSL certificate is](https://comparehostingonline.com/guides/what-is-an-ssl-certificate/).
-   Real visitor IP addresses may be hidden from your logs unless you configure the forwarding header.
-   Another vendor to depend on.

## Does a CDN improve time to first byte?

For cached files, yes: the response comes from nearby, so the first byte arrives sooner. For uncached dynamic pages, no: the request still has to reach your origin, and the CDN adds only a small hop. If your problem is a slow server, a CDN will hide part of it for cached content but will not fix it. Read [what TTFB is](https://comparehostingonline.com/guides/what-is-time-to-first-byte/) to separate the two.

## Who needs a CDN?

Sites with visitors in several countries, image-heavy pages, large downloads and sites with traffic spikes gain the most. A local business whose visitors are all near the server gains less, but the free tier of many CDNs is still worth turning on for the security and compression features. Shops and busy [WordPress sites](https://comparehostingonline.com/hosting-types/managed-wordpress/) benefit the most because they serve many assets per page.

## How do you choose a CDN service?

A CDN service is the company that runs the network, and the choice matters less than turning one on correctly. Compare services on the points below rather than on a headline price, and read each provider’s own documentation for the current numbers.

| What to check | Why it matters |
| --- | --- |
| Pricing model | Some charge per gigabyte delivered, some per request, some a flat monthly fee. A small site on a free tier pays nothing; a download-heavy site can pay a lot. |
| Locations near your visitors | A network with servers close to your audience does more for speed than a network with more locations elsewhere. |
| Cache control | You need to set how long files are kept and to clear a file when you change it. |
| HTTPS and protocols | Look for free certificates, HTTP/2 and [HTTP/3](https://comparehostingonline.com/guides/what-is-http-3-and-hosting/) support. |
| Security extras | Many CDN services add DDoS protection and a [web application firewall](https://comparehostingonline.com/guides/what-is-a-web-application-firewall/); check what is included and what costs extra. |
| Setup effort | A CDN built into your host needs no DNS changes; a separate service usually needs DNS or nameserver changes. |
| Support and limits | Check the free tier’s limits, how support works and how easy it is to switch away. |

If your host already includes a CDN, start there and measure before adding another service. See [do you need Cloudflare?](https://comparehostingonline.com/guides/do-you-need-cloudflare/) for the most common separate option, and [what is time to first byte](https://comparehostingonline.com/guides/what-is-time-to-first-byte/) for a measurement that shows whether a CDN helped.

## How do you set up a CDN?

There are two common methods. A CDN built into your host is switched on in the control panel and needs no DNS changes. A separate CDN either acts as a reverse proxy (you point your nameservers or DNS records at it) or serves a dedicated asset hostname such as cdn.example.com that you reference in your pages. After setup, test that pages still load over HTTPS, that logged-in pages are not cached, and that updated files appear after you purge. Our [nameservers guide](https://comparehostingonline.com/guides/nameservers-explained/) covers the DNS side.

## A worked example: what a CDN does to a page’s requests

A page needs 40 requests: one HTML file, five scripts, three stylesheets, two fonts and 29 images. Without a CDN, a visitor in another continent sends all 40 requests to your origin, each taking a long round trip. With a CDN in front, the HTML is sometimes served from the edge too, and the 39 static files come from a server a few milliseconds away. The origin only sees the requests the CDN could not answer, such as personalised pages.

The page may finish loading in under two seconds instead of five for that visitor, and your host handles a small fraction of the original load. This is the typical gain: it is large for distant visitors and image-heavy pages, and small for a local audience on a lightweight site.

## What cache rules should you set first?

| Content | Suggested rule |
| --- | --- |
| Images, fonts, scripts and styles | Cache for a long time, version file names when they change |
| Public HTML pages | Cache for a short time, purge on update |
| Cart, checkout and account pages | Do not cache |
| Admin and login pages | Do not cache, restrict access |
| API responses | Cache only if safe and public |

## Does a CDN help SEO?

Not directly. A CDN is not a ranking factor. It helps indirectly, because faster loading improves how people experience your pages, and Core Web Vitals, such as Largest Contentful Paint, are part of Google’s page experience signals; see web.dev. Faster pages can also reduce bounces. A CDN also adds resilience: a site that stays up during a spike is crawled and used normally. Be careful with configuration: serve the same content to crawlers and visitors, keep canonical URLs on your own domain, and make sure the CDN does not block legitimate crawlers.

## Sources and further reading

-   [MDN: HTTP caching](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Caching)
-   [web.dev: Content delivery networks](https://web.dev/articles/content-delivery-networks)
-   [Cloudflare Cache documentation](https://developers.cloudflare.com/cache/)
-   [RFC 9000: QUIC](https://www.rfc-editor.org/rfc/rfc9000)

## Common questions

What does a CDN do?

A content delivery network caches copies of your static files, such as images, CSS and scripts, on servers around the world and serves each visitor from a nearby one. It makes pages load faster and reduces the load and traffic on your host.

Do I need a CDN for a small website?

Not strictly, but it often helps and many have free tiers. It benefits sites with distant visitors, many images or traffic spikes. Local sites gain less, though the security and compression features can still be worth enabling.

Is a CDN the same as web hosting?

No. Hosting stores your site and runs its code. A CDN sits in front of it and caches copies. You still need hosting, and the CDN fetches from it when it has no fresh copy.

Can a CDN break my site?

A wrong setup can. Cached pages may show old content until purged, logged-in or cart pages must not be cached, and SSL mode mismatches can cause redirect loops. Test after enabling and set sensible cache rules.

How do I clear a CDN cache?

Use the purge option in the CDN dashboard to remove a single URL or everything. Many WordPress caching plugins and hosts can purge automatically when you publish. Purge after deployments so visitors see the new files.

## Related

[What is TTFB?](https://comparehostingonline.com/guides/what-is-time-to-first-byte/) [Best cloud hosting](https://comparehostingonline.com/best/cloud-hosting/) [Who hosts this website?](https://comparehostingonline.com/tools/who-hosts-this/)

## More guides

[Website backups: what to back up, how often and how to test a restore](https://comparehostingonline.com/guides/website-backups-guide/) [Cloud hosting vs VPS hosting: differences, costs and which to choose](https://comparehostingonline.com/guides/cloud-vs-vps-hosting/) [Managed vs unmanaged VPS: who does what and which to choose](https://comparehostingonline.com/guides/managed-vs-unmanaged-vps/) [How to secure a new VPS: a first-hour hardening checklist](https://comparehostingonline.com/guides/how-to-secure-a-vps/) [What is DDoS protection in hosting? What it covers and what to ask](https://comparehostingonline.com/guides/what-is-ddos-protection/)

MH

**[Muhammad Hamza](https://comparehostingonline.com/team/muhammad-hamza/)** Founder & Editor

Writes and signs off every comparison, and runs the compliance reviews. Has worked on SOC 2 and HIPAA compliance programs for companies.

Our [editorial policy](https://comparehostingonline.com/editorial-policy/) and [testing method](https://comparehostingonline.com/methodology/) are public.
