Skip to content
BENIBIX Learn

Cache

Development⚙️ Compilers & RuntimesPerformance

Also known as Caching, Cached, Cache Hit, Cache Miss

A fast store of copies. The same data loads quicker next time.

Think of it like

Think of it like keeping your snacks on your desk. You do not walk to the kitchen each time.

Example

Emma's shop page asks the database for the same 20 best sellers on every visit. She caches the list for 5 minutes, and the page loads 10 times faster.

Why it matters

A cache is one of the cheapest ways to make an app fast. It also takes load off the database.

Definition

A cache is a small, fast store that keeps copies of data you are likely to need again. The first time, the data comes from the slow place, like a database or another server. A copy is kept in the cache. The next time, it comes from the cache, which is much faster. Finding the data there is a cache hit, and missing it is a cache miss.

Common mistake

Caching data that changes often, then showing people old prices or stock. Every cache needs a plan for when its copy goes stale.

Key takeaways

  1. 1
    Keep a copy. Near where it is used.
  2. 2
    Hit or miss. Found, or fetched again.
  3. 3
    Copies go stale. Plan when to refresh.