CompareHostingOnline

Home / Guides / CDN service explained: what it does, free options and how to choose one

Guide

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.

By Muhammad Hamza, Founder & EditorUpdated Nov 30, 2026
Scales with demand

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
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. The visitor requests a file

    Their browser asks for an image or script on your domain.

  2. The nearest edge answers

    If it has a cached copy, it sends it at once.

  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. 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?.

Web hostingCDN
Stores your site filesYes, the originalsCopies, temporarily
Runs your code and databaseYesNo
Where it sitsOne or a few locationsMany locations worldwide
Main jobRun the siteDeliver files fast and absorb load
Can you use one without the other?YesNo, a CDN needs an origin

What are the benefits?

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.
  • 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 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 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 checkWhy it matters
Pricing modelSome 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 visitorsA network with servers close to your audience does more for speed than a network with more locations elsewhere.
Cache controlYou need to set how long files are kept and to clear a file when you change it.
HTTPS and protocolsLook for free certificates, HTTP/2 and HTTP/3 support.
Security extrasMany CDN services add DDoS protection and a web application firewall; check what is included and what costs extra.
Setup effortA CDN built into your host needs no DNS changes; a separate service usually needs DNS or nameserver changes.
Support and limitsCheck 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? for the most common separate option, and 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 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?

ContentSuggested rule
Images, fonts, scripts and stylesCache for a long time, version file names when they change
Public HTML pagesCache for a short time, purge on update
Cart, checkout and account pagesDo not cache
Admin and login pagesDo not cache, restrict access
API responsesCache 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

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

More guides

Esc

Use the arrow keys, then Enter.