Skip to content
hostcomplex

Cache Hit vs Miss

Maarten Soetens 2 min read

Hits, Misses and Expired Entries Explained

Cache hit vs miss describes whether a request can be answered from storage. A cache hit happens when the requested item is already stored and still valid, so it is served straight from the cache. A cache miss happens when the item is not stored, so the request goes to the origin server, and the result may then be stored for next time.

A third case is the expired entry. The cache holds a copy, but its lifetime has ended. Depending on the system, the cache either checks with the origin whether the copy is still current or fetches a new version. Expired entries are usually counted as misses, because the origin still has to do some work.

A visit to a page cached a minute earlier is a hit. The first visit after a new deployment, or after content has been purged, is usually a miss. The cache warming technique can reduce such first-visit misses by filling the cache in advance.

Calculating the Cache Hit Ratio

The cache hit ratio is the share of requests served from the cache. It is calculated as hits divided by total requests and is usually shown as a percentage. If a cache serves 900 requests from storage and passes 100 to the origin, the hit ratio is 90 percent.

A high ratio means the cache is doing its job. Most visitors receive stored copies, and the origin handles only a small share of the load. A low ratio means the cache is seldom used, so the speed and load benefits stay small.

A Low Ratio on a Busy Online Shop

An online shop finds that only 20 percent of its requests are hits. Most product pages carry a session cookie, which makes the cache treat many visits as different and store little that can be reused. Once the shop stops setting that cookie on product pages and keeps those pages for a short time, more requests become hits, and the origin handles a smaller share of the traffic. Pages that must stay personal still need to skip the cache, as explained in the cache bypass article.

Frequently asked questions

What is a good cache hit ratio?

There is no single target, because the right figure depends on the site. Sites with mostly static content can often reach very high ratios, while sites with many personal pages will always have lower ones. A better question is whether the ratio is rising over time and whether the origin is handling less load as a result.

Does a cache miss mean the cache is broken?

No. Misses are normal for new content, expired entries and requests the cache is not meant to store. A cache only has a problem when content that should be cacheable keeps missing. Watching the trend over time shows whether the cache is working as intended.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.