What is a CDN?

DEFINITION

A CDN (content delivery network) is a network of servers around the world that stores copies of your site's files and serves each visitor from a nearby location for faster loading.

A content delivery network is a group of servers, often called edge locations or points of presence, spread across many cities. When a visitor requests your site, DNS or routing sends them to the nearest edge server. If that server already has a cached copy of the file, it responds immediately; if not, it fetches it from your origin server, stores it and serves it.

CDNs mainly cache static assets such as images, CSS, JavaScript, fonts and video, but many can also cache full HTML pages and run small pieces of code at the edge.

Why a CDN matters

Physical distance adds delay to every request. A visitor in Sydney loading a site hosted only in Virginia waits longer for each file than one served from a local edge. A CDN reduces that delay, which improves load time and metrics like Largest Contentful Paint.

Because the edge handles most requests, your origin server does less work and copes better with traffic spikes from a sale or viral post. Many CDNs also include DDoS protection, a web application firewall and free TLS certificates.

How to use a CDN effectively

Start by putting static assets behind the CDN with long cache lifetimes, for example Cache-Control: public, max-age=31536000, immutable for files whose names include a version hash like app.3f9a1c.js. When you deploy a new version the filename changes, so visitors get the new file without needing to purge the cache. For HTML, use shorter lifetimes or stale-while-revalidate so content stays fresh. Never cache pages that show personal data, such as carts or account dashboards, unless the CDN is configured to vary by user.

Best practices

  • Use versioned filenames for CSS and JavaScript so you can cache them for a long time safely.
  • Serve images through the CDN in modern formats such as WebP or AVIF where supported.
  • Exclude logged-in, cart and checkout pages from shared caching.
  • Check response headers to confirm assets are actually returning cache hits.

Common mistakes

  • Caching personalized pages so one visitor sees another visitor's data.
  • Setting long cache times on files without versioned names, then wondering why updates do not appear.
  • Assuming a CDN fixes a slow server for uncached, dynamic requests.

Frequently asked questions

Do small websites need a CDN?

Not always, but it usually helps and is often free or included with modern hosting. If your audience is spread across regions or your pages are image-heavy, a CDN makes a noticeable difference. Even for a local business, the security features and reduced server load can justify enabling one.

Does a CDN help SEO?

Indirectly. A CDN does not change rankings by itself, but faster pages improve Core Web Vitals and user experience, which Google considers. It can also improve reliability during spikes. Make sure the CDN does not block search engine crawlers and that canonical URLs remain consistent.

What is cache purging?

Purging tells the CDN to delete cached copies of specific files or the whole site so the next request fetches fresh content from your origin. It is useful after urgent fixes. Relying on versioned filenames for assets means you rarely need to purge, which keeps cache hit rates high.

Need help with this?

Cloud & DevOps by VYZEON — Une infrastructure qui s'adapte, se déploie et se rétablit d'elle-même.

Fixed packages from $199. Written scope, no surprises.

See Cloud & DevOps

Related terms

More Web development terms