What is a CDN, and does a business website need one?

Web8 min readBy the UC Tech team

A CDN, or content delivery network, is a group of servers spread across many locations that keep copies of your website's files and serve each visitor from a server near them. Your own server, called the origin, still holds the master copy. The CDN sits in front of it, answering most requests itself so pages arrive faster and your server does less work.

Many business websites with visitors from more than one city benefit from a CDN, and for many sites it is part of the hosting plan already. This guide explains how a CDN works, what it should and should not cache, and how to decide whether you need one.

How a CDN works, in plain terms

Without a CDN, every visitor's browser talks directly to your server. If your server is in one city and your customer is in another state or country, every request makes that round trip. Each trip adds delay, and setting up a secure connection takes several trips before the first byte of your page arrives.

With a CDN, the visitor connects to the nearest CDN server, often called an edge server or point of presence. Then one of two things happens:

  • Cache hit. The edge server already has a fresh copy of the file and sends it straight away. Your server is not involved at all.
  • Cache miss. The edge server does not have the file, or its copy has expired. It fetches the file from your origin server, sends it to the visitor and keeps a copy for the next person.

Even on a miss, or for a page that cannot be cached, the visitor can still gain. As Google's web.dev guide explains, the secure connection is set up close to the visitor, and the CDN can reach your origin over connections that are already open, so less time is spent on setup.

What a CDN should cache, and what it should not

The key decision is what the CDN is allowed to store and share between visitors. Get this wrong and you either gain nothing, or, worse, show one customer's page to another.

Type of contentExamplesCache on the CDN?
Static filesImages, CSS, JavaScript, fonts, PDFs, videoYes, for a long time, ideally with versioned file names so a new version gets a new name
Public pages that change now and thenHome page, service pages, blog postsUsually yes, with a shorter lifetime and a purge when you publish
Busy dynamic responsesProduct stock lists, public API responsesSometimes, for a few seconds, to absorb traffic peaks
Personal pagesCart, checkout, account, admin, anything after loginNo. Mark them private or no-store

Google's web.dev guidance suggests long cache lifetimes, such as six months to a year, for static files that rarely change, and notes that caching busy dynamic content for very short periods, such as five seconds, can significantly reduce the load on the origin during heavy traffic.

How your server tells the CDN what to do

Caching rules travel with each file in an HTTP header called Cache-Control. You or your developer set it on the server or in the CDN dashboard. The directives you will see most often:

  • max-age: how many seconds a response stays fresh.
  • s-maxage: how long a response stays fresh in a shared cache such as a CDN. It overrides max-age for shared caches and is ignored by private caches such as the browser's.
  • private: only the visitor's own browser may store this response. A CDN must not share it.
  • no-store: no cache of any kind should store the response.

When you change a page or file before its lifetime runs out, you purge it: you tell the CDN to drop its copy so the next request fetches the new version. CDNs typically let you purge through an API, and many also offer a dashboard and ways to purge a group of files at once. Many website platforms can do this automatically when you publish.

What a CDN does for a business website

  • Faster pages for distant visitors. Files come from a nearby server, so round trips are shorter. This helps the loading measures covered in our guide to Core Web Vitals.
  • Less load on your server. Every cache hit is a request your server never sees. That can let a modest hosting plan handle more visitors.
  • Steadier during peaks. A sale, a newspaper mention or an ad campaign can multiply traffic. The CDN absorbs much of it.
  • Modern delivery features. Many CDNs offer Brotli or gzip compression, TLS 1.3 and HTTP/2 and HTTP/3, and some can resize and convert images to newer formats such as WebP on the fly.
  • Security add-ons. Many CDN providers also sell security features. Check exactly what your plan includes rather than assuming.

Does your business website need a CDN?

Use this quick guide. If two or more of the "likely yes" rows describe you, a CDN is worth setting up.

Your situationCDN?
Visitors come from many cities or from abroadLikely yes
Your server is far from most of your customersLikely yes
Pages carry large images, galleries or videoLikely yes
Traffic spikes during campaigns, sales or launchesLikely yes
Online store with many product imagesLikely yes, with careful rules for cart and checkout
Small local site, server in the same region as all customers, light pagesHelpful but not urgent
Internal tool used only on the office networkUsually not needed

Before adding one, check what you already have. Many hosting plans and website platforms include a CDN, and some static site hosts serve everything from a CDN by default. Our comparison of shared hosting, VPS and cloud explains how the hosting choice fits in.

Setting up a CDN: the steps

  1. Check your current setup. Ask your host or developer whether a CDN is already in front of the site, and where your origin server is located.
  2. Choose a provider. Look for edge locations near your customers, a clear way to purge, cache analytics, and support for HTTPS on your own domain.
  3. Point traffic through it. This is usually a DNS change: either you move your domain's DNS to the CDN, or you point a record at the address it gives you. Plan it for a quiet hour.
  4. Set caching rules. Long lifetimes for versioned static files, shorter ones for public pages, and private or no-store for anything personal.
  5. Exclude logged-in areas. Make sure admin, cart, checkout and account pages bypass the cache. Log in and out in two different browsers to confirm nobody sees another person's page.
  6. Test forms and integrations. Submit your contact form and test payments, webhooks and any login flow.
  7. Watch the numbers. Most CDNs provide cache analytics, including the cache hit ratio: hits divided by all requests. Google's web.dev guide calls 90 percent a good goal for most sites.

Common CDN mistakes to avoid

  • Caching personal pages. The most serious mistake. One customer's cart or details shown to the next visitor is a privacy incident.
  • Forgetting to purge. You update prices or a phone number and visitors still see the old version. Set up purging on publish.
  • A low hit ratio nobody notices. Tracking parameters, cookies or a Vary header can make the CDN store many copies of the same page. Review the analytics after launch.
  • Ignoring the origin. A CDN hides a slow server only on cache hits. Every miss and every logged-in page still depends on your hosting.
  • Losing control of the account. The CDN account controls your traffic. Keep it in the company's name with more than one admin, just like your domain and hosting.

If you would like a CDN set up properly on a new or existing site, see our website development service or talk to us.

Frequently asked questions

Is a CDN the same as web hosting?

No. Hosting is where the master copy of your site lives and runs. A CDN sits in front of the host and serves copies of files from servers near your visitors. You still need hosting.

Will a CDN improve my Google ranking?

A CDN can make pages load faster, which visitors notice, but no technical change guarantees a ranking. Useful, relevant content still matters most.

Why does my site still show old content after I edited it?

The CDN is serving a cached copy that has not expired. Purge the changed page or file in your CDN dashboard, or set up automatic purging when you publish.

Can a CDN work with WordPress or an online store?

Yes. Static files are cached as usual, and pages for logged-in users, the cart and checkout are set to bypass the cache. Test these carefully after setup.

Sources

Want this built for your business?

UC Tech builds software, apps, websites and WhatsApp automation.

Start a project