Skip to content

How to Connect a CDN to Your Site

Key idea:

CDN (Content Delivery Network) — geographically distributed servers serving static content from the node closest to the user. For a standard site setup takes 30 min: register at Cloudflare (free), switch DNS, enable proxy, set cache rules. For RU — Yandex Cloud CDN (DC in Moscow).

Below: step-by-step, working examples, common pitfalls, FAQ.

Check your site →

Step-by-Step Setup

  1. Register at CDN (Cloudflare free)
  2. In dashboard add the domain → import existing DNS records
  3. At the registrar switch nameservers to Cloudflare (craig.ns.cloudflare.com, etc.)
  4. Wait for propagation (1-24 h). Enterno DNS checker shows when done
  5. In Cloudflare enable: "Proxy" (orange cloud) on A records for edge caching
  6. SSL/TLS mode: Full (strict) — if origin has cert. Full (not strict) — if self-signed.
  7. Cache rules: Static Files → Cache Everything, TTL 1 year
  8. Verify: curl -I https://example.com | grep -i "cf-cache-status" → "HIT"

Working Examples

ScenarioConfig
Cloudflare Page Rule for cacheURL: example.com/static/* → Cache Everything + Edge Cache TTL: 1 year + Browser Cache TTL: 1 year
AWS CloudFront distributionOrigin: your-bucket.s3.amazonaws.com Alternate Domain Names (CNAMEs): cdn.example.com Default Cache Behavior: Redirect HTTP to HTTPS + Cache based on Host header
Yandex Cloud CDNCreate CDN resource → Primary origin: origin.example.com Edge locations: Moscow + Saint-Petersburg SSL: Let's Encrypt or custom cert
nginx origin behind CDNreal_ip_header CF-Connecting-IP; set_real_ip_from 173.245.48.0/20; # Cloudflare IP ranges
Cache bust via query paramhttps://example.com/style.css?v=1776446434 # filemtime hash auto-bust

Common Pitfalls

  • Cloudflare SSL "Flexible" + HTTPS redirect in PHP = redirect loop
  • Cache rules on dynamic endpoints (/api/*, /admin/*) — serves stale data to everyone
  • Origin sees client IP as Cloudflare → all logs = 173.245.x.x. Fix: real_ip_header CF-Connecting-IP.
  • CDN caches Set-Cookie headers — users see each other's sessions. Bypass cache for /api.
  • Redirect chain longer (www → non-www → HTTPS → CDN) — LCP degrades. Consolidate.

TL;DR: Setting Up a CDN with Cloudflare, AWS, and Yandex

To set up a CDN using Cloudflare, AWS, or Yandex in 2026, start by creating an account with your chosen provider. For Cloudflare, simply add your domain, change your DNS settings to point to Cloudflare's nameservers, and configure performance settings. On AWS, use Amazon CloudFront: create a distribution, link it to your S3 bucket or EC2 instance, and adjust caching settings. For Yandex, register your domain, set up a CDN project, and configure your web server to use Yandex’s edge nodes.

Step-by-Step Guide to Setting Up a CDN with Cloudflare

Cloudflare is one of the most popular CDN solutions due to its ease of use and robust features. Follow these steps to set it up:

  1. Create a Cloudflare Account: Go to Cloudflare's website and sign up for an account.
  2. Add Your Site: After logging in, click on ‘Add a Site’ and enter your domain name (e.g., example.com).
  3. Choose a Plan: Select a plan that suits your needs; the free plan is suitable for most small to medium-sized websites.
  4. Change Your Nameservers: Cloudflare will provide you with two nameservers. Go to your domain registrar (like GoDaddy or Namecheap) and update your DNS settings to point to these nameservers.
  5. Configure DNS Settings: In the Cloudflare dashboard, navigate to the DNS settings. Ensure that your A and CNAME records are correctly configured. For example, if you have an A record for www pointing to your server IP, it should appear as:
Type: A
Name: www
Content: 192.0.2.1
  1. Adjust Performance Settings: Go to the 'Speed' tab and enable features like Auto Minify for CSS, JavaScript, and HTML. Use the 'Rocket Loader' feature to improve loading times for JavaScript-heavy sites.
  2. Set Up Page Rules: Under the 'Page Rules' section, configure rules to optimize caching and security. For example, you can set a rule to cache everything at example.com/*.
  3. Enable SSL: For secure connections, enable SSL in the 'SSL/TLS' settings. Choose the 'Full' option to encrypt traffic between Cloudflare and your server.
  4. Monitor Performance: Use Cloudflare's analytics tools to track performance improvements and adjust settings as necessary.

By following these steps, you can effectively set up Cloudflare as your CDN, enhancing your website's speed and reliability.

Configuring a CDN with AWS CloudFront

Amazon CloudFront is a powerful CDN that integrates seamlessly with AWS services. Here’s how to set it up:

  1. Log into AWS Management Console: Navigate to the CloudFront service.
  2. Create a Distribution: Click on ‘Create Distribution’ and select ‘Web’ as the delivery method.
  3. Configure Origin Settings: Set the origin domain name to your S3 bucket or EC2 instance URL. For example, if using an S3 bucket, it might look like example-bucket.s3.amazonaws.com.
  4. Set Default Cache Behavior: Configure the default settings for how CloudFront caches content. Set Viewer Protocol Policy to ‘Redirect HTTP to HTTPS’ for security.
  5. Configure Distribution Settings: Under ‘Distribution Settings,’ set the price class based on your expected traffic regions (e.g., Price Class All for global coverage).
  6. Enable Logging: Enable logging to track how your CDN is performing. This can be useful for troubleshooting and performance optimization.
  7. Deploy the Distribution: Click on ‘Create Distribution’ and wait for the status to change from ‘In Progress’ to ‘Deployed’ (this can take up to 30 minutes).
  8. Update DNS Records: Update your domain's DNS settings to point to the CloudFront distribution's URL (e.g., d12345abcdef8.cloudfront.net).
  9. Test the Setup: After the distribution is deployed, test your website to ensure that content is being served via CloudFront. You can use tools like WhatsMyDNS to check DNS propagation.

By leveraging AWS CloudFront, you can efficiently distribute content globally while ensuring low latency and high availability.

Learn more

Frequently Asked Questions

Cloudflare or Yandex Cloud CDN?

Cloudflare: global coverage, free, but not every Russian ISP routes optimally. Yandex: tier-1 RU coverage + compliance, paid from 0.5₽/GB.

How much does CDN speed up the site?

International client TTFB: 300-800ms → 50-150ms. LCP: 10-40% improvement depending on content.

How to purge CDN cache?

Cloudflare: Dashboard → Caching → Purge Cache (all or by URL). AWS: Invalidation in CloudFront console. Yandex: Prefetch/Purge API.

Does a CDN help SEO?

Yes. Google uses TTFB + Core Web Vitals. Fast CDN → better CWV → +10-20% visibility.

Try the live tool that powered this guide

Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.