Skip to content

What is a CDN?

By Ash, Founder, HosteazePublished 2 min read

A CDN (content delivery network) is a group of servers in many locations that keep copies of your website's files, such as images, stylesheets and scripts. Visitors get those files from the nearest server rather than your host, so pages load faster for distant visitors and your own server has less work to do.

A satellite-style map of the Earth at night with city lights scattered across every continent, like the locations a CDN serves files from.
Credit: 14398 via Pixabay

Without a CDN, every visitor to your site fetches every file from one place: your hosting server. That's fine when your visitors are nearby. When someone in Lisbon or Sydney opens a page hosted in Manchester, each request makes a long round trip, and a page with 60 files makes a lot of them.

How does a CDN work?

Cloudflare's own documentation gives the example of a visitor in Paris reaching a site hosted in Los Angeles: the first Parisian gets a copy fetched from LA, and the next ones get the copy stored in Paris.

What does a CDN store, and what doesn't it?

Usually cachedUsually not cached
Images, video and fontsYour HTML pages (unless you set a rule)
CSS stylesheetsBasket, checkout and account pages
JavaScript filesAnything that changes for each visitor
PDFs and downloadsAdmin areas such as /wp-admin

The left-hand column is where the speed comes from, because those files are the bulk of most pages. The right-hand column matters for shops and membership sites. Cache a basket page by mistake and one customer could see another's items, which is about as awkward as a support ticket gets.

What else does a CDN do?

Because a CDN sits between visitors and your server, it can do more than speed things up. Many CDNs, Cloudflare among them, also work as a reverse proxy: they hide your server's real IP address, soak up traffic floods such as DDoS attacks, and handle the SSL certificate encryption work so your server doesn't have to.

Do I need a CDN?

Here's our rule of thumb. If your visitors are mostly in one country and your server is in the same country, a CDN is helpful but optional, so fix images and caching first. If your visitors are spread across the UK, Europe or further, it's worth setting up, because the distance saving is real. And if you run a shop or busy blog with traffic spikes, set one up mainly to take load off your server.

Cloudflare, for one, has a free plan that includes its CDN. If your site still feels slow after adding one, the problem is probably closer to home. Our guides on why your WordPress site is slow and how to speed up WordPress cover the usual suspects.

Frequently asked questions

Is a CDN the same as web hosting?

No. Your host still runs your website and stores the original files. The CDN sits in front of it and hands out copies of files that don't change often, going back to your host whenever it needs a fresh copy.

Does a CDN help if all my customers are in the UK?

Less than you might think. If your server is already in the UK, the distance a UK visitor's request travels is short. A CDN can still take load off your server and absorb traffic spikes, but sorting out heavy images and plugins usually makes a bigger difference.

Will a CDN cache my WordPress pages?

Not by default with most CDNs. Cloudflare, for example, caches files such as images, CSS and JavaScript by file extension but does not cache HTML unless you add a rule. Pages that change per visitor, like a basket or account page, should never be cached.

Sources

  1. MDN Web Docs, CDN
  2. Cloudflare Docs, How Cloudflare works
  3. Cloudflare Docs, Default cache behavior

Hosting made for WordPress

See how our WordPress hosting is set up.

See WordPress hosting