Serving Dynamic Content with a Modern CDN
Traditional CDNs have conditioned users into thinking content falls into two fundamental types: static and dynamic. Let's break down what each of these means to better understand how to use them.
What is Static Content?
Static content has been defined as "whatever a traditional CDN can cache". Static content is the same for all users and is faster to deliver.
What is Dynamic Content?
Dynamic content is "everything else." Meaning, dynamic content is generated by the sever for every request. It can take a lot more effort to deliver.
We've long believed that this distinction has more to do with CDN technology than the content itself. To a traditional CDN, only content with long, well-defined lifetimes counts as "static" and therefore cacheable. But by using modern CDN features like cache invalidation, real-time metrics, and edge delivery, new categories of previously "dynamic" content become available for caching. The content hasn't changed, but the technology has.
What’s the challenge?
Personalized content (often falling under that “dynamic” definition) is becoming ever more important. In fact, 74% of respondents in an Instapage survey said they feel frustrated when a site isn’t personalized. And with current circumstances driving more purchases online, personalization matters more than ever.
However, traditional CDNs aren’t able to cache this dynamic, personalized information (think: account info, location-specific products, changing inventory, local headlines, etc.), which means traditional CDN customers find more of their traffic going all the way back to the origin, resulting in slower response times and more expensive infrastructure, including the cost of egress data for all those responses.
Beyond cacheability there are a few other reasons that continue to block traditional CDNs from serving more cached content at the edge:
Visibility: content served from the origin shows up immediately in metrics, while traditional CDN stats and logging can be difficult to integrate and take minutes or hours to arrive.
Consistency: often when one piece of content is updated, many others need to be purged along with it in order to maintain integrity and avoid stale results. For example, on an ecommerce site, photos and SKUs may need to change when a product description is modified.
Mixed content: cache-unfriendly technologies like GraphQL may mix a small amount of personalized content, like a shopping cart, with a large amount of otherwise-cacheable content, like photos and descriptions of the cart items.
What’s the solution?
Modern CDNs make it possible to serve truly dynamic content that changes with every request from the edge instead of the origin. By giving you the ability to run your code closer to the end user — with more strategically placed high-capacity POPs that also act as a storage pool to cache more content — it’s possible to eliminate many origin requests entirely.
The modern CDN’s ability to instantly purge (measured in milliseconds by some CDNs) and selectively purge content (as opposed to “purge all”) helps companies cache a lot of content that would otherwise be uncachable with traditional CDNs.
Additionally, a modern CDN gives developers real-time visibility into stats and logs to program and monitor API performance. These mechanisms are powerful enablers for content delivery and help multiple facets of organizations' applications, including performance, origin offload, and overall insight.
Serverless computing at the edge takes this even further. We argue for an edge-first mindset that doesn't worry about static versus dynamic any longer but starts by building everything at the edge and only pushes limited use cases to the origin (more on accelerating those use cases in a future post).
Looking forward to the next generation of edge delivery, our own serverless compute environment, Compute@Edge, allows for content stitching. This allows you to arbitrarily combine content both from cache and from origin into a single response in order to serve as much content as possible from the edge while still being able to personalize responses to each individual user. Watch Fastly Chief Architect Sean Leach give a demo of using Compute@Edge to stitch GraphQL content and more at Altitude.
These are just a few of the many ways a modern CDN and edge-based serverless architecture help serve more dynamic content and improve user experiences. Explore more on this topic and what else you can do with a modern CDN in our Guide to the Modern CDN: security and performance for today’s developer.