Home / Blog / Hosting Fundamentals / CDN vs Web Hosting and When You Need Both

Hosting Fundamentals

CDN vs Web Hosting and When You Need Both

“Should I get a CDN or better hosting?” is one of the most common questions in website performance — and it is based on a misunderstanding. A CDN (Content Delivery Network) and web hosting are not alternatives. They do different jobs, at different layers, and most established sites benefit from both. The trick is knowing what each one does, and when adding a CDN is genuinely useful versus when it is just another layer of complexity.

What Web Hosting Does

Web hosting is where your website lives. The origin server stores your files and database, runs your application (WordPress, a shop, a custom app), generates pages, processes logins, handles checkout and talks to the database. Every dynamic action on your site — publishing a post, placing an order, logging in — happens on the origin server.

Hosting determines your site’s fundamental capacity: how much CPU and memory it has, how fast its storage is, which PHP version it runs, and how many simultaneous requests it can handle. If the origin server is slow or overloaded, no CDN can fix that — it can only reduce how often visitors need to reach it.

What a CDN Does

A CDN is a geographically distributed network of edge servers that cache copies of your content close to your visitors. When someone requests your site, the request is routed to the nearest edge location. If the content is cached there, the edge server answers immediately — a cache hit — and your origin server is never involved. If it is not cached, the edge server fetches it from the origin, serves it, and stores a copy for the next visitor — a cache miss.

Cloudflare, one of the largest CDN providers, describes the effect plainly: content is served from a city near the user rather than from a single faraway server, which cuts the round-trip distance and the time each request takes. Its network spans more than 300 cities, and static content is cached automatically once a site is proxied through it.

A CDN typically provides three things beyond caching:

  • Lower latency for distant visitors. A visitor in another country no longer waits for every image, stylesheet and script to travel to and from your single server.
  • Less load on the origin. Every cache hit is a request your server never sees, which frees capacity for the dynamic work only the origin can do.
  • Absorption of traffic spikes. A surge of visitors is served largely from cache, so the origin does not collapse under the load. This is why a CDN is part of any serious traffic spike preparation.

Many CDNs also bundle security features — DDoS mitigation, a web application firewall, and TLS termination — because all traffic passes through their network before it reaches your origin.

What a CDN Caches — and What It Does Not

This is where most confusion lives. By default, a CDN caches static content: images, CSS, JavaScript, fonts and other files that do not change per visitor. Dynamic content — HTML pages that depend on who is logged in, a shopping cart, an admin dashboard — is not cached by default, because serving a cached copy could show one visitor another visitor’s data.

You can configure a CDN to cache HTML as well (using cache rules), but this needs care: pages must be cached only for anonymous visitors, and the cache must be purged whenever content changes. A misconfigured HTML cache can serve stale prices, outdated stock levels or, worse, a logged-in user’s page to a stranger. If you are not confident about cache rules, leave HTML uncached and let the CDN handle static assets — that alone covers most of the performance benefit for a typical site.

When You Need a CDN

A CDN is worth having when one or more of these apply:

  • Your visitors are geographically spread out. If a meaningful share of your audience is on another continent from your server, a CDN is the single most effective way to cut their load times.
  • Your pages are asset-heavy. Image-rich sites, media sites and e-commerce catalogues benefit the most, because most of their page weight is cacheable.
  • You expect traffic spikes. A sale, a viral post, a press mention — a CDN absorbs the surge from cache instead of overwhelming your origin.
  • You want the security layer. DDoS protection and a WAF in front of your origin are genuinely useful for any public site, and they come bundled with most CDN services.

When a CDN Will Not Help

A CDN is not a cure for a slow site, and it can be the wrong investment in several situations:

  • Your audience is local and your server is nearby. If your visitors and your server are in the same region, the latency a CDN saves is small.
  • Your origin server is the bottleneck. If Time to First Byte is high because the database is slow or PHP is outdated, the CDN will still have to wait for the origin on every dynamic request and every cache miss. Fix the origin first — see how to diagnose a slow WordPress site.
  • Your site is almost entirely dynamic. A members-only dashboard, a web app with personalised content on every page, or an admin panel will see little benefit from edge caching.
  • Your site is tiny and low-traffic. A small brochure site with a few dozen visitors a day will not notice a CDN. The added configuration and the risk of caching mistakes outweigh the gain.

A CDN also adds a layer you must understand: cache purging after content changes, cache headers, and the interaction between the CDN and your site’s own caching plugin. Two caching layers that disagree produce confusing bugs — pages that update for you but not for visitors, or vice versa.

How Hosting and a CDN Work Together

The healthy architecture is simple: hosting does the dynamic work, the CDN does the distribution.

  1. The origin server runs the application, generates pages, handles logins and checkout, and serves anything that must be fresh.
  2. The CDN sits in front of it, serving cached static assets from edge locations, absorbing spikes, and filtering malicious traffic.
  3. Your site’s own caching (page cache and object cache on the origin) reduces the work the origin does for each request, so cache misses are fast too.

Each layer helps the others. A fast origin makes cache misses cheap; a CDN makes the origin’s remaining work lighter; good caching on the origin makes the CDN’s job easier. None of them substitutes for the others.

Setting Up a CDN: The Practical Steps

  1. Choose a provider. The well-known options include Cloudflare, Fastly and Amazon CloudFront. Compare on the features you need — many sites start with a free tier, which covers basic caching and DDoS protection.
  2. Point your DNS at the CDN. The provider gives you nameservers or a CNAME to configure at your domain registrar. This is the step that routes traffic through the CDN, and it is the step to get right: a DNS mistake takes the site offline.
  3. Confirm caching is working. Load a page twice and check the response headers for a cache status such as HIT on static assets. If everything is a MISS, the configuration is not engaged.
  4. Set up cache purging. Know how to purge the cache — manually, or automatically when content changes. WordPress plugins exist that purge the CDN cache on publish; many hosts integrate this directly. [TO BE CONFIRMED: whether Offshore Hosting plans include CDN integration or automatic cache purging.]
  5. Test from multiple locations. Use a speed test tool with test locations in the regions your visitors come from, and compare before and after. Judge the result with field data where possible — see Core Web Vitals for WordPress site owners.

The Bottom Line

If your site has a global audience, heavy assets or spike-prone traffic, a CDN is one of the best performance investments you can make. But it is an addition to good hosting, not a replacement for it. A fast origin server with a CDN in front of it beats a slow origin with a CDN every time — because the CDN can only ever serve what the origin can produce.

Sources

  • Cloudflare: What is a CDN?: https://www.cloudflare.com/learning/cdn/what-is-a-cdn/
  • Cloudflare Cache (CDN): Get started with Cache: https://developers.cloudflare.com/cache/get-started/
  • Cloudflare CDN reference architecture: https://developers.cloudflare.com/reference-architecture/architectures/cdn/
  • Web Vitals — web.dev: https://web.dev/articles/vitals

Sources

  • {‘title’: ‘Cloudflare: What is a CDN?’, ‘url’: ‘https://www.cloudflare.com/learning/cdn/what-is-a-cdn/’}
  • {‘title’: ‘Cloudflare Cache (CDN): Get started with Cache’, ‘url’: ‘https://developers.cloudflare.com/cache/get-started/’}
  • {‘title’: ‘Cloudflare CDN reference architecture’, ‘url’: ‘https://developers.cloudflare.com/reference-architecture/architectures/cdn/’}
  • {‘title’: ‘Web Vitals — web.dev (Google Chrome team)’, ‘url’: ‘https://web.dev/articles/vitals’}

← All guides · Knowledge Base

Related guides