Chapter 3. Intentional Cache Rules

In this chapter we will look at different types of content we can cache, but first let’s start by quickly covering some concepts that apply to what we will be talking about:

  • Hot, warm, and cold cache
  • Cache freshness

Hot, Warm, and Cold Cache

There are several states cache can be in:

Cold cache

A cold cache is empty and results in mostly cache misses.

Warm cache

The cache has started receiving requests and has begun retrieving objects and filling itself up.

Hot cache

All cacheable objects are retrieved, stored, and up to date.

Cache starts cold, either with no objects stored or with any that are stored stale. Then over time, and as requests start coming in, the server retrieves the objects and fills the cache. A hot cache will start to cool and turn cold as time goes by and the content starts to expire.

Cache Freshness

A cold cache can also be the result of expired content, based on the max-age directive specified. A cache is considered fresh if it’s creation date is within the max-age. That window is its time to live (sometimes called TTL). See Figure 3-1 for a pattern that describes the warming and cooling of cache.

Figure 3-1. Cold cache warming and cooling over time and requests

Now that we understand what the concept of cache is, as well as the types of caches and the benefits that we can get from using them, let’s talk about the types ...

Get Intelligent Caching now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.