CDN Basics: Cache Hit, Cache Miss, Time To Live (TTL)

A CDN or Content Delivery Network is critical to video, image, and website content delivery and performance across the globe. Services like The Wall Street Journal, Netflix, Amazon Prime, HBO, YouTube, and most high-traffic websites and applications depend on CDNs for their day-to-day existence and to ensure extremely high quality of service, quality of experience, and cost reduction.

While working with CDNs, there are a couple of terminologies you need to know such as Cache Hits, Cache Misses, and Time to Live. Knowing what they mean can help you operate, maintain, and optimize your CDNs for greater performance.

But first, what is a Cache? If you have read our introduction to CDNs article, you’d know that

A content delivery network (CDN) is a system of distributed servers that are deployed in multiple locations around the world. These servers are connected to the Internet and are used to store and deliver web content, such as HTML pages, images, and videos, to users based on their geographic location.

A CDN is essentially a network of servers that act as temporary storage for frequently accessed content. These temporary storages are also referred to as “caches”.

When a user requests content (webpage, image, video), the request is routed to the correct server on the CDN, which then retrieves the content from its cache (a temporary storage area for frequently accessed data) and delivers it back to the user.

With this basic information, let’s start learning about cache hits, misses, and TTLs.

Cache Hit in a CDN

A CDN (Content Delivery Network) cache hit occurs when the CDN is successfully able to serve a requested asset from its cache rather than having to retrieve it from the origin server. To put it another way, the request “hit” the CDN’s cache successfully and did not need to be served from the origin.

Why is it vital to track the CDN Hit metric?

Well, CDN Hits greatly improve the performance of a website (or app) by reducing the time it takes to deliver content to the end user. When a CDN cache hit happens, the requested object is directly provided from the CDN’s cache, which is frequently situated closer to the end user than the origin server.

This can greatly speed up the delivery of the asset, giving users a quicker and more responsive experience.

You may significantly boost the number of CDN Hits and enhance the performance of your streaming services/website by ensuring that the most popular content is cached on the CDN and rarely-requested content is removed from the CDN cache.

Cache Miss in a CDN

A cache-miss occurs when a client requests the CDN for some particular content, and the CDN has not cached that content.

When a cache miss occurs, the CDN requests the origin server for that missing content. After the Origin Server responds with the content, the CDN caches the content and serves it to the client.

A Cache Miss can occur for a number of reasons, such as,

  • the requested content not being present in the CDN’s cache, or,
  • the content might have been evicted from the cache, or,
  • the content is being requested for the first time and hence, not available in the cache

When a Cache miss occurs, it can result in a slower user experience because the asset must be retrieved from the origin server which may be located farther away from the end user. And, consequently, take longer to deliver.

Hence, it is important to ensure that the most important and frequently requested content is cached on the CDN.

CDN Time-to-Live or TTL

Till now, we learned about CDN Hits and CDN Misses and these refer to the presence of content on a CDN Cache. A CDN Miss occurs because the CDN has evicted or removed content from the CDN’s cache. This is because, a CDN does not cache segments or any other media indefinitely.

Instead, a CDN uses a variable called “Time to Live” or TTL to flush its cache of infrequently requested content. Simply put, the TTL specifies how long the asset will be stored in the CDN’s cache before it expires and must be re-fetched from the origin server.

The TTL can be set by the user in the CDN’s configuration (if the origin server does not provide a value). It is usually set as a relative time, such as “24 hours,” or as an absolute time, such as “March 4, 2000.”

Why is the CDN TTL value important?

First of all, a properly configured TTL value ensures that a CDN’s cache is regularly flushed to make space for newer content and to manage disk space intelligently.

Secondly, the purpose of the TTL is to ensure that the CDN’s cache is kept up-to-date with the latest version of the asset. If the TTL has expired, the CDN will re-fetch the asset from the origin server the next time it is requested. This helps to ensure that end users are always served the most up-to-date version of the asset.

Finally, the TTL can be set differently for different types of assets. E.g., the TTL for static and rarely-changing assets such as CSS files may be set to a long value, whereas, the TTL for dynamic content such as news articles can be set to a smaller value to ensure frequent updates.

How to Increase the CDN Hits and Reduce CDN Misses?

To increase the number of CDN Hits and thereby reduce the number of CDN misses, a variety of strategies can be employed depending on the nature of the application and the requirements. Here are some ideas –

Increasing the Time To Live or TTL

By increasing the TTL or Time To Live values for certain popular assets, one can ensure that the number of hits increase and the misses drop. On the flip side, this strategy should be used carefully to ensure that the cache does not get filled with less-popular content and runs out of space.

Intelligent cache eviction policies

The cache eviction policies can be made more intelligent based on geographies, time zones, time-of-the-day, etc. to ensure that the most popular content is present on the CDN and the rest are evicted.

Prefetching or Cache Warming

These are methods for pre-populating the cache with assets that are likely to be requested in the future. For example, if an episode of a popular series is going live, it makes sense to pre-populate the CDN with video segments and increase the number of CDN Hits when people begin watching the series.

Learn More About CDNs

To learn more about CDNs (Content Delivery Networks), do check out OTTVerse’s CDN series.

  1. How does a CDN work?
  2. What is the Thundering Herd Problem in CDNs? What is Request Collapsing?
  3. How does a Multi-CDN work?
  4. What is the advantage of using a CDN for Live Streaming?

krishna rao vijayanagar
Krishna Rao Vijayanagar

Krishna Rao Vijayanagar, Ph.D., is the Editor-in-Chief of OTTVerse, a news portal covering tech and business news in the OTT industry.

With extensive experience in video encoding, streaming, analytics, monetization, end-to-end streaming, and more, Krishna has held multiple leadership roles in R&D, Engineering, and Product at companies such as Harmonic Inc., MediaMelon, and Airtel Digital. Krishna has published numerous articles and research papers and speaks at industry events to share his insights and perspectives on the fundamentals and the future of OTT streaming.

1 thought on “CDN Basics: Cache Hit, Cache Miss, Time To Live (TTL)”

  1. Pingback: Using Origin Shields for Amazing CDN Performance & Video Streaming: Benefits and Providers - OTTVerse

Leave a Comment

Your email address will not be published. Required fields are marked *

Enjoying this article? Subscribe to OTTVerse and receive exclusive news and information from the OTT Industry.