Updated on April 17, 2025
·Originally published on November 5, 2015
Most high-traffic apps and websites need a content delivery network (CDN). Without a CDN, content will take longer to load, and the interface will be slow to react to user actions, which can cause users to leave, resulting in higher bounce rates.
Everyone wants their content to be delivered rapidly and reliably, but not everyone has the time and resources to integrate their own CDN.
This article will go over what a CDN is, what its benefits are, and how Contentful integrates one to deliver content as fast as possible.
A content delivery network (CDN) is a network of servers, typically distributed globally. The purpose of using a CDN is to have content delivered to worldwide users faster. For a small personal website or a blog, one virtual private server is enough, but for a website with 25k hits per second, it just does not work, as your server will become overloaded. A CDN provides the ability to cache content (including static assets), reducing the load on your main server and improving performance.
When a CDN is in place, every incoming request will be typically routed to the server with the lowest latency, to maximize the delivery speed: a visitor from Germany gets content from a server in Frankfurt, and a user from somewhere in California is greeted by a machine in San Francisco. If the server either doesn't have the file cached or is overloaded, the request is forwarded to the next best server based on latency, rather than whichever is closest.
A CDN distributes content over a number of worldwide edge locations, typically referred to as points of presence (PoP), so the content is closer to where the user is requesting it, reducing latency.
Here's what will typically happen under the hood when a user visits a website with a CDN:
The user visits the website, which requests some content; it could be an image or a video file.
The domain name system (DNS) forwards the request to the closest CDN edge location.
The CDN server checks if it has a cached copy of the content; if cached, it gets delivered immediately.
If the content isn't cached, the CDN fetches it from the origin server.
The content is sent to the user and cached for future use.
Now future users requesting this content will get it immediately (see step 3).
CDNs are typically used to deliver static content such as images, videos, and files like JS and CSS, which must be available everywhere. Caching this content at edge locations leads to a better user experience by reducing latency. As you can imagine, if your origin server is in France and a user in China makes a request, serving the content from a nearby PoP in China will result in faster delivery for the user.
Beyond just caching, CDNs can compress files, reducing bandwidth with image optimization and minification. Additionally, using a CDN will reduce the load on your origin server as it won't constantly have to be serving high-bandwidth assets such as images and videos, freeing up resources for database queries or other backend processes. This not only improves scalability but can also prevent server overload during traffic spikes.
As well as reducing latency and minimizing server load, CDNs can benefit your application in a number of different ways:
Caching: By keeping copies of earlier requested documents and making them available for future requests, caching greatly speeds up content delivery.
Improved availability: If your origin server happens to go down, the CDN can continue to serve content, minimizing downtime.
Enhanced security: By distributing content over multiple locations, CDNs can provide protection against DDoS attacks, improving the security of your application.
Global reach: By distributing your content worldwide, you ensure a consistent experience for all of your users no matter where they are in the world.
SEO benefits: By improving web page load time and reducing any downtime, CDNs can help contribute to better search engine rankings, as load speed is a crucial factor in SEO.
Real-time logs: Some CDN providers give you access to real-time logs at the edge, which give you information on traffic, performance, and even security threats.
Although it comes with benefits, there are some challenges to consider before implementing a CDN:
Cost considerations: Many CDN providers charge you based on bandwidth usage, which can become costly for high-traffic websites, especially if the CDN hasn't been set up or optimized correctly.
Cache invalidation and stale content: Caching content can speed up delivery, but it can also lead to outdated data being served if the CDN is not configured to refresh content properly when updates take place.
Latency in cache misses: If the file is not cached at the edge server, the request will be forwarded to the origin server, which can introduce latency and potentially reduce the CDNs performance benefits. This is more of a problem for dynamic content that is more difficult to cache. Although tiered caching or stale-while-revalidate can help with this, they require more work to set up. Even with cache misses, a CDN still improves overall efficiency compared to not using one by optimizing routing and reducing requests to the origin server.
Compliance: Distributing content over multiple different locations can create compliance issues with data privacy regulations such as GDPR. While this can be a problem, some CDNs do offer a way to restrict data being sent to different regions.
Security risks and misconfigurations: If you configure your CDN poorly it can actually lead to more security issues rather than solving them. A badly configured CDN can lead to data leaks, improper access controls, or cache poisoning attacks.
Below is a table of some of the most popular CDN offerings and how they differ in the services they offer.
Feature | Amazon CloudFront | Fastly | Cloudflare |
---|---|---|---|
Performance (latency and speed) | High performance, optimized for AWS workloads | Very low latency, optimized for performance | Low latency with strong caching capabilities |
Global network coverage | 200+ PoPs worldwide | 80+ PoPs with strategic locations | 310+ data centers globally |
Edge computing support | AWS Lambda@Edge | Compute@Edge for serverless apps | Cloudflare Workers for edge computing |
DDoS protection | Included with AWS Shield Standard | Advanced protection with Fastly WAF | Enterprise-grade DDoS protection |
Pricing model | Pay-as-you-go, based on usage | Pay-as-you-go, tiered pricing | Freemium, Pro, Business, and Enterprise plans |
Ease of integration | Deep AWS integration | Highly configurable, but complex setup | Easy setup with DNS integration |
Real-time analytics | Basic logging, AWS CloudWatch | Detailed real-time logs and dashboards | Advanced analytics and insights |
Cache purging | Fast, but not instant | Within milliseconds | Instant cache purging |
Below are a few points to consider when deciding whether your application needs a CDN or not:
For international apps: You may want to consider using a CDN if your application is serving a global audience or is growing more international, allowing the users who are accessing content in different parts of the world to receive data from the nearest servers.
For a growing user base: If your user base begins to grow and you have many concurrent users or you experience a sudden spike in traffic, CDNs can help to distribute the load efficiently, reducing latency and preventing server crashes.
To serve large static files: If you're serving large static files like images or videos from your origin server and it's starting to cause latency issues, it might be time to start using a CDN so you can cache these high-bandwidth assets and reduce the load on your main server.
For protection against security threats: CDNs can offer security settings such as traffic filtering and DDoS mitigation, which will improve security and protect your application from malicious attacks.
CDNs are useful when building content-heavy applications like marketing or ecommerce websites. If you’re looking to build these kinds of applications, you’ll benefit greatly from a content management system (CMS) to organize and manage your content effectively.
Setting up your own CDN can be complex and requires you to configure and maintain your solution manually. Platforms such as AWS offer CDN tools such as CloudFront, but you need to set it up and monitor it with your own custom settings for optimal performance, which can take time and cost money if not implemented correctly. While most modern CMS platforms now support CDNs, this typically means integrating third-party services.
Luckily, Contentful, being a composable content platform, comes with a properly set up CDN, meaning if you use Contentful for content management, you get reliable and fast delivery by default. No technical maintenance and setup efforts are needed from your side.
Contentful has two different built-in CDNs to optimize content delivery — under the hood, the Content Delivery API , a read-only API that is designed to deliver published content from Contentful's cloud-based content platform to your web applications, is using Fastly for JSON documents, and the Images API, which allows you to retrieve and manipulate media assets, uses CloudFront. Each one is optimized to perform its particular job well.
Fastly is a modern CDN with strong geographical presence used by some renowned companies such as Vimeo, X (Twitter), GitHub, and many others. Contentful relies on Fastly to rapidly respond to every API request with a JSON document.
Going a bit deeper, we've selected Fastly because of some features not offered by its competitors. Apart from being present in 80+ locations on six continents, it also enables purging the cache after every content update in under 150 milliseconds. This means our users always receive the most up-to-date content as quickly as possible.
CloudFront, as mentioned earlier, is another industry standard — a CDN provided by Amazon as a part of its AWS cloud products. Used for delivering media assets and binary files in Contentful, it's notable for great location coverage. Our setup includes long expiration time to maximize caching, and also generates URLs for new assets on every update, so they feel instant.
Contentful’s CDNs have automatic caching built in, so it works out of the box without extra configuration. You can also turn on advanced caching options, which allows you to enable one or both of the following options:
Stale-when-rate-limited: When traffic is high and requests hit the rate limit, stale content is served instead of an error; this ensures continuous availability, useful for heavy traffic.
Stale-while-revalidate: After publishing, stale content is served for a minute while the cache updates in the background; this prevents delays and is good for handling many identical requests with low latency.
If you need to check the status of Contentful's CDN quickly or want to see the performance metrics, you can find all of the information you need at Contentful Status. This is the page to visit if you want to see whether a service is down or if you want to check on the performance metrics of our services. If you go there now, you should see that the Content Delivery API is operational.
If you're building something that requires a CDN and you're thinking of using a CMS, then it makes sense to choose Contentful: a composable content platform that comes with the minimum amount of setup so you can spend valuable development time solving other problems.
The Contentful CDN ensures rapid and reliable content delivery, not just in theory, but in practice: you can see for yourself by taking a look at the (rather reassuring) latest performance metrics. Using the Contentful platform comes with the huge benefit of having exactly zero work to do when it comes to setting up a CDN: we've got you covered, and you can simply enjoy up to 99.99% uptime.
Subscribe for updates
Build better digital experiences with Contentful updates direct to your inbox.