Back to all questions

How Does CDN Deliver Dynamic Content?

Alex Khazanovich
Dynamic Content
May 5, 2024

CDNs are increasingly leveraging the following techniques to address this challenge:

  • Reduced TLS handshake latency: Edge servers are closer to users, lowering handshake time.
  • Prefetching: Content is delivered before requested, improving speed.
  • Faster routing: CDN infrastructure offers a reliable and faster path for requests.
  • Edge computing: Latest innovation for further improvements.

Let’s take a look at each of these in detail below:

Early Innovations in CDN Technology

Even before the advent of edge computing, CDNs had already transformed content delivery through several technologies:

1. Reduced TLS Handshake Latency

By offloading the TLS handshake to edge servers, which are geographically closer to users, CDNs significantly lower the time required for this essential security protocol. 

This reduction in round-trip time (RTT) enhances the speed and security of data transfers.

2. Content Prefetching

This technique involves predicting user behavior and proactively storing certain dynamic content on edge servers before it's even requested. It's essentially the CDN making an educated guess about what users might want to see next.

This works well for predictable user patterns. For instance, a CDN managing a sports website might pre-load content previews and live scores for upcoming matches during peak hours in a specific region. 

By having these previews readily available on the edge server, the CDN can deliver them almost instantaneously when a user clicks on a match link. This anticipation translates to a faster and more engaging user experience.

3. Smart Routing

CDNs consider factors like a user's location, network congestion, and server health to determine the most efficient route for delivering content. This ensures users are directed to the edge server with the best possible connection, minimizing delays and creating a smoother experience. For dynamic content, this process involves more than just connecting to the nearest edge server.

Imagine a user in London trying to access a live news broadcast from a server in Sydney. While the CDN efficiently routes the user to the closest edge server, for dynamic content like a live broadcast, the data must still interact with the origin server in Sydney. 

The CDN leverages its internal backbone to route this dynamic content from the edge server back to the origin server and then to the user in the most efficient way possible. This optimization minimizes latency and maximizes speed, ensuring a seamless viewing experience.

Modern CDNs and Edge Computing

Edge computing refers to placing mini-data centers, equipped with processing power and storage, at geographically distributed points on the network's "edge" – closer to users. 

These mini-data centers house "edge functions" – small programs specifically designed to run on the CDN's edge servers. The integration of edge computing is constantly evolving, and there are more than a few ways how CDNs tackle dynamic content delivery.

Here's how edge computing empowers CDNs to handle dynamic content caching more effectively:

1. Partial Caching of Dynamic Content

While the core dynamic content might still be generated by the origin server, edge functions can cache certain elements that change less frequently. For instance, an e-commerce website's product categories or a news platform's pre-built news modules can be cached on the edge server. 

When a user requests the dynamic page, the CDN can deliver these cached components instantly, while fetching the truly dynamic elements (like personalized product recommendations or real-time news updates) from the origin server. This reduces the overall load time for the user.

If you’re unsure of why dynamic content is so different, check out: Dynamic Content vs Static Content.

2. Offloading Tasks from the Origin Server

Edge functions can also handle specific tasks associated with dynamic content delivery. Imagine a website conducting A/B testing on different layouts. Traditionally, the origin server would need to handle the logic and deliver the appropriate layout for each user.

With edge computing, the CDN's edge functions can take over this task, determining the user's location and delivering the relevant layout variant, reducing the workload on the origin server and potentially speeding up response times.