What is a CDN? Content delivery networks explained

How content delivery networks make websites faster and more resilient, what caching means, and how to set up a CDN without breaking your site.

By the UK Technology Hub teamPublished 4 minute read

The short answer

A content delivery network (CDN) is a group of servers around the world that store copies of your website's files and deliver them from the location nearest each visitor. That makes pages load faster, reduces load on your main server and helps absorb traffic spikes and some attacks. Most modern hosting includes a CDN; the key is configuring caching rules correctly.

When someone in Sydney visits a website hosted in London, data has to travel halfway around the world. Each round trip adds delay. A content delivery network shortens that journey by keeping copies of your content close to visitors everywhere.

How a CDN works

  1. Your website lives on an origin server, your main hosting.
  2. The CDN has edge servers in many cities worldwide.
  3. When a visitor requests a file, the nearest edge server checks whether it has a copy.
  4. If it does (a cache hit), it serves it immediately.
  5. If not (a cache miss), it fetches the file from the origin, sends it to the visitor and keeps a copy for next time.

What gets cached

Static assets are ideal: images, CSS, JavaScript, fonts, videos and downloadable files. They change rarely and are the heaviest parts of most pages.

Whole pages can be cached too, especially for static or rarely changing sites. Our guide to Jamstack explains sites built to be served entirely from a CDN.

Personalised content, such as shopping baskets, account pages and checkout, must not be cached in a way that shows one user's data to another.

The benefits

Speed. Shorter distances and optimised networks mean faster loading, especially for visitors far from your origin.

Lower server load. The origin handles fewer requests, reducing hosting costs and improving stability.

Handling traffic spikes. Cached content can serve huge numbers of visitors without overwhelming your server.

Security. Many CDNs include protection against distributed denial-of-service attacks, web application firewalls and bot management. Combined with good security headers, they strengthen your site's defences.

Extra features. Image optimisation, automatic compression, modern protocols and HTTPS certificates are often built in.

Cache rules that matter

Cache lifetime. How long the CDN and browsers keep a copy, set through cache-control headers. Long lifetimes suit versioned assets, such as files with a version number in the name; short lifetimes suit content that changes.

Cache keys. What makes a request unique: URL, query strings, cookies, device type or language.

Bypass rules. Pages that must never be cached, such as checkout and account areas.

Cache invalidation

When you update content, cached copies may be stale. Options include:

  • Purging specific files or the whole cache.
  • Versioned file names, so updated assets get new URLs and caches naturally refresh.
  • Short cache times for frequently updated pages.
  • Automatic purges triggered by your CMS or deployment platform.

Common mistakes

  • Caching pages with personal data, causing privacy leaks.
  • Forgetting to purge after important updates, so visitors see old prices or information.
  • Caching error pages.
  • Blocking legitimate bots, including search engines, with overly strict bot rules.
  • Not testing forms, logins and checkout after enabling the CDN.

Measuring CDN performance

After setup, check the cache hit ratio, the share of requests served from the edge rather than your origin. A low ratio suggests cache rules need adjusting. Compare page load times from different regions before and after, using testing tools with locations around the world. Watch origin server load too; it should drop noticeably once caching is working.

Do you need a CDN?

If your visitors are spread across regions, your site has many images, you expect traffic spikes or you want better protection, a CDN is worth it. Many hosting platforms and website builders already include one; check before buying separately.

Costs

Pricing varies: many providers offer free or low-cost tiers for small sites, with charges based on bandwidth, requests and advanced features for larger ones. For most small and medium business sites, CDN costs are modest compared with the performance benefits.

Setting up a CDN

  1. Check whether your host or platform already provides one.
  2. If adding one, point your DNS through the CDN or configure it as instructed. Our guide to DNS records explains the settings involved.
  3. Set cache rules for static assets and pages.
  4. Exclude dynamic and personal pages.
  5. Enable HTTPS and modern compression.
  6. Test the whole site, especially forms, logins and checkout.
  7. Monitor cache hit rates and performance.

How we help

Our web development team configures CDNs and caching for speed and safety. Our e-commerce team sets correct cache rules for stores, and our maintenance plans include monitoring performance and purging caches after updates.

Frequently asked questions

Does a CDN make my website faster?

Usually, especially for visitors far from your hosting location and for sites with many images and scripts.

Can a CDN break my website?

Misconfigured caching can show stale or personal content. Careful rules and testing prevent this.

Is a CDN the same as web hosting?

No. Hosting stores the original site; a CDN distributes copies globally. Many hosts include a CDN.

This guide is general information, not legal, tax or financial advice, and details such as prices, features and rules can change. Product and company names mentioned are trademarks of their respective owners and are used only to identify those products; UK Technology Hub is not affiliated with or endorsed by them.

Related guides

All websites & web design guides