What is a content delivery network (CDN)?
A CDN keeps copies of your website on servers in many places, so each visitor is served from one nearby. What it speeds up and what it cannot.
A content delivery network (CDN) is a group of servers spread over many locations that keep copies of a website’s files. Each visitor is served from a server close to them, so the files have less distance to travel.
How it works
Your website still lives on your own hosting, which a CDN calls the origin. The CDN’s servers sit in front of it, in data centres around the world. They are often called edge servers, because they are at the edge of the network nearest the visitor.
- A visitor in Perth asks for your home page. The request goes to the CDN server nearest to them.
- If that server already holds a copy of the file, it sends it straight back.
- If it does not, it fetches the file from your origin, sends it to the visitor and keeps a copy for the next person. Keeping the copy is called caching.
The files that suit this best are the ones that are the same for everybody and rarely change: images, video, style sheets and scripts.
What it is good for
- Speed. A shorter trip means the page starts arriving sooner. Google’s guidance says CDNs are particularly good at improving how quickly the main content of a page appears, one of the Core Web Vitals.
- Less load on your server. Requests answered from a copy never reach the origin. That lowers the work your hosting has to do and helps it through a sudden rush of visitors.
- Protection from floods of traffic. In a denial-of-service attack, someone tries to overwhelm a site with requests. CISA lists a CDN among the measures that help against hostile traffic, and the Australian Signals Directorate suggests choosing one that can filter attacks before they reach your server.
What to watch
A CDN works in front of hosting and cannot stand in for it. If the origin is slow at building pages, visitors still wait for anything the CDN has to fetch fresh.
Copies can go stale. When you change a file, the old version may keep being served until the copy runs out its set time or is cleared by hand, which is called purging. If you have ever updated a page and still seen the old one, this is a likely cause.
Pages that belong to one person, such as an account page or a shopping cart, should not be stored on a CDN at all. Whoever sets it up needs to mark those as private.
The origin also still needs protecting. The Australian Signals Directorate advises against disclosing the origin server’s address where it can be avoided, so that an attacker cannot go around the CDN.
Does your site need one?
It helps most when visitors are far from the server, when pages carry a lot of images or video, or when traffic arrives in bursts. A small site whose customers are all in the same city as its server gains less. Google’s guidance notes that results vary by location, so it is worth measuring before and after.
Ask your host or developer whether a CDN is already in front of your site. If speed is the concern, start with Is your website too slow for Google and your customers?, or talk to us about website optimisation.
Sources
- Content delivery networks (CDNs) (web.dev, Google) web.dev
- CDN (MDN Web Docs, Mozilla) developer.mozilla.org
- Preparing for and responding to denial-of-service attacks (Australian Signals Directorate) cyber.gov.au
- Website security (CISA) cisa.gov