Docs / Performance Optimization / Using Content Delivery Networks for Speed

Using Content Delivery Networks for Speed

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 31 views · 1 min read

What is a CDN?

A Content Delivery Network distributes your static assets (images, CSS, JS) across servers worldwide. Visitors load files from the nearest server, dramatically reducing latency.

How CDNs Work

  1. You configure your CDN to pull content from your origin server
  2. When a visitor requests a file, the CDN serves it from the nearest edge location
  3. If the edge doesn't have the file (cache miss), it fetches from your origin and caches it

Popular Free CDN Options

  • Cloudflare — free tier includes CDN, DNS, basic DDoS protection, and SSL
  • BunnyCDN — pay-as-you-go starting at $0.01/GB

Setting Up Cloudflare

  1. Sign up and add your domain
  2. Point your nameservers to Cloudflare
  3. Enable "Proxied" mode on your DNS records (orange cloud icon)
  4. Configure caching rules under Caching → Configuration

Cache Headers for CDN

# Nginx — set proper cache headers
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2)$ {
    expires 30d;
    add_header Cache-Control "public, immutable";
    add_header Vary "Accept-Encoding";
}

Measuring Impact

Test your site speed before and after CDN setup using:

  • Google PageSpeed Insights
  • GTmetrix
  • WebPageTest

Was this article helpful?