CDN vs Web Hosting
Two Different Jobs in Delivering a Website
CDN vs web hosting is less a contest than a question of roles, because each does a different job. Web hosting stores a website's files and runs its applications. A content delivery network is a delivery layer that keeps copies of those files on servers around the world and serves them to visitors from the closest point.
In most setups the two work together. The hosting account holds the original files and database, which is called the origin. The CDN sits in front, answers requests for cached content and passes other requests back to the origin. Without the hosting, there would be no source for the content in the first place.
Where Each One Fits in a Typical Site
A typical business or blog site uses hosting for its pages, databases, email and control panel. It may then add a CDN to speed up images, scripts and stylesheets for visitors far from the server. Hosting remains necessary for anything the CDN cannot produce alone, such as a contact form that saves data to a database.
A CDN does not replace the work of building pages. If the origin is slow to generate a page, the CDN can only pass that slowness on to visitors who miss the cache. Caching at the edge helps most when the origin is reasonably quick and the same content is requested many times. The trade-offs are weighed in the benefits and drawbacks article.
The Exception: Static Sites Served from the Edge
Some sites are built only from HTML, CSS and JavaScript files and published directly to a CDN or static hosting platform. In that case there is no separate server running application code, and the edge network itself serves every file. This suits brochures, documentation and portfolios.
The model does not work for sites that need a database, user accounts or server-side code. Those sites still need an origin that can run the code, which is why hosting remains the foundation for most websites.
Frequently asked questions
Can I use a CDN without web hosting?
Yes, but only when the content does not need a server to run. A site made of static files can be served entirely from a CDN or static hosting platform. A site that runs PHP, uses a database or processes forms needs an origin that can execute that code, which means hosting of some kind.
Will a CDN fix a slow website?
Not by itself. A CDN can make cached files arrive faster, but it cannot make the origin generate pages faster. Requests that miss the cache still wait for the origin, plus the extra step through the network. Slow database queries, heavy page code and oversized images must be addressed at the source.