What Is a CDN? How It Works and What It Does
What is a CDN and how does it work? How a content delivery network speeds up your site, cache settings, Cloudflare setup, DDoS protection and game servers.

Contents
A CDN (Content Delivery Network) is a network that keeps copies of your website's images, CSS, JavaScript, video and other files on servers in different parts of the world and serves each visitor from the closest location. Even if your site sits on a server in Frankfurt, a visitor in Tokyo gets the files from a nearby CDN server. The result: pages that load faster, a main server under less load and an extra layer of protection against attacks.
In this post we explain what a CDN is, how it works, what it brings to your site, how to set one up with Cloudflare and why it works differently for game servers.
How does a CDN work?
CDN providers have data centers all over the world called edge servers or PoPs (Points of Presence). Once your site is connected to a CDN, the process works like this:
- A visitor opens your site. DNS sends them to the CDN server closest to them.
- The CDN server checks whether the requested file is in its cache.
- If it is in the cache (cache hit), it sends the file straight to the visitor. Your main server isn't contacted at all.
- If it isn't in the cache (cache miss), it fetches the file from your main server (the origin), sends it to the visitor and stores it for a while for the next visitors.
This way an image comes from your main server the first time it's requested and from the CDN for the thousands of requests that follow. Because the distance to the visitor is shorter, latency drops; we explained why latency grows with distance in our What is ping? post.
What does a CDN do?
- Speed: Files come from a location close to the visitor. The difference is especially large for sites that get visitors from different countries.
- Less server load: Since most static files are served from the CDN, your main server only handles dynamic requests. Your site stays up during sudden traffic spikes.
- Bandwidth savings: The amount of data leaving your server goes down.
- Security: CDNs hide your main server's IP address and filter DDoS attacks aimed at web traffic on their own network. We covered the types of attacks in our What is DDoS? post.
- Resilience to outages: Some CDNs can keep serving cached pages when the main server is briefly unreachable.
What content gets cached?
| Content type | Is it cached? |
|---|---|
| Images, videos, fonts | Yes, these benefit the most |
| CSS and JavaScript files | Yes |
| Static HTML pages | Yes, with rules |
| Dynamic pages like WordPress | Partly; except for logged-in users |
| Cart, checkout, admin panel | No, these must always come from the main server |
| API responses | Usually not |
How long content stays in the cache is decided by the Cache-Control header your server sends or by the rules in the CDN dashboard. It is critical that personalized content (cart, account page) is not cached; otherwise one user's page could be shown to another user.
Does every site need a CDN?
It isn't essential for every site. If most of your visitors are in a region close to your server and your traffic is low, the gain stays limited. A CDN makes a real difference especially when:
- You get visitors from different countries and continents.
- Your site has a lot of images, videos or downloadable files.
- You see sudden traffic spikes during campaigns and announcements.
- You want to protect your site against attacks aimed at web traffic.
Setting up a CDN with Cloudflare
Cloudflare is one of the most widely used CDNs thanks to its free plan. Setup usually goes like this:
- Create a Cloudflare account and add your domain. Cloudflare scans and imports your existing DNS records.
- Check the records; if any are missing, especially MX and TXT records, add them by hand.
- Replace your domain's nameservers in your registrar's dashboard with the addresses Cloudflare gives you. This change can take a few hours to propagate.
- Make sure the orange cloud (Proxied) is on for the A and CNAME records that point to your website. The orange cloud routes traffic through the CDN; the grey cloud (DNS only) only provides DNS.
- Set SSL/TLS to Full (strict). For this, your hosting server needs a valid SSL certificate. "Flexible" mode doesn't encrypt the traffic between Cloudflare and your server and can cause redirect loops.
We explained how DNS records work in our What is DNS? post and SSL settings in our What is an SSL certificate? post.
Things to watch out for when using a CDN
- Real visitor IP address: With the proxy on, your server sees requests as if they came from the CDN's IP addresses. To see the correct IP in logs, security plugins and rate limits, your server needs to be set up to read the header the CDN adds (
CF-Connecting-IPon Cloudflare). - Keep your main server's IP address hidden: If the main IP address of a proxied site shows up in another record (for example an unproxied
ftpormailrecord), attackers can bypass the CDN and reach the server directly. - Clearing the cache: If you see old files after updating your site, clear the cache from the CDN dashboard. Adding a version to file names (
style.css?v=2) solves this problem for good. - Exclude the admin panel: Leave admin paths such as
/wp-adminout of your cache rules.
Game servers and CDNs
CDNs are designed for the web. Cloudflare's standard proxy only carries HTTP and HTTPS traffic; it doesn't carry the TCP and UDP traffic of games such as Minecraft, FiveM or Rust. That's why:
- Add records that point to your game server, such as
mc.yourdomain.com, with the grey cloud (DNS only). With the orange cloud on, players can't connect. - These records show your server's real IP address; what protects a game server against attacks is not the CDN but the DDoS protection in front of the server.
- If the game uses a non-default port and the game supports it, you can add an SRV record so players can connect without typing a port. Minecraft Java Edition, for example, supports the
_minecraft._tcpSRV record. We explained how to set up a Minecraft server in our How to make a Minecraft server guide.
CDNs with Nodesty
Nodesty web hosting plans are already fast with the LiteSpeed web server and NVMe storage; by adding a CDN such as Cloudflare in front of them, you can make pages load even faster for your visitors in other countries. Thanks to the free SSL certificate, you can use Cloudflare in the secure Full (strict) mode. If you host your own applications or game servers, the L3–L7 nShield DDoS protection on our AMD Ryzen 9 9950X VPS plans also protects the game traffic a CDN doesn't carry.
Frequently Asked Questions
Do I need to change hosting to use a CDN?
No. A CDN is an extra layer placed in front of your existing hosting. Your site stays on the same server; the CDN keeps copies of your content on servers close to your visitors. Usually all you need to change is your DNS settings.
Is a CDN free?
Some providers, such as Cloudflare, have free plans that are enough for small and medium-sized sites. Other CDNs usually charge based on the amount of data transferred. Features such as image optimization, advanced security rules and dedicated support are found on paid plans.
Does a CDN affect SEO?
Indirectly, and in a positive way. Page speed and Core Web Vitals are taken into account in search rankings, and a CDN makes pages load faster, especially for distant visitors. Wrong cache settings, however, can lead to outdated content being shown, so they need to be configured carefully.
I updated my site but the change doesn't show up. Why?
The CDN may be keeping the old version in its cache. Ask for the relevant URL or the entire cache to be cleared (purged) from the CDN dashboard. Adding a version number to the names of CSS and JavaScript files prevents this problem for good.
Can I put my Minecraft server behind Cloudflare?
Cloudflare's free proxy only carries web traffic (HTTP and HTTPS). You need to add the records for Minecraft and other game servers with the proxy turned off (grey cloud, DNS only); otherwise players can't connect. Protecting game servers against attacks requires DDoS protection on the server side.
What is the difference between a CDN and web hosting?
Web hosting stores your site's actual files and database and runs code such as PHP. A CDN sits in front of that server and serves copies of static files from locations close to your visitors. A CDN doesn't host a site on its own; it needs hosting behind it.
About the author
Nodesty Team · Infrastructure & Support
The Nodesty team runs our servers, network and DDoS protection day to day and answers customer support requests around the clock. These guides come from that work.
Related articles

What Is a Subdomain and How Do You Create One?
What is a subdomain and how do you create one? Subdomains with DNS records, creating one in cPanel and DirectAdmin, pointing it to a game server, and SSL.

What Is Bandwidth and Traffic? Calculate Your Needs
What is bandwidth, and how does it differ from traffic? Mbps vs. MB/s, port speed, unlimited traffic, sizing for websites and game servers, and monitoring.

How to Change the PHP Version and php.ini Settings
How to change PHP version: choosing a version in cPanel and DirectAdmin, upgrading safely, and php.ini settings like memory_limit and upload_max_filesize.