← Back to your curiosity
software · 5 STEPS

Why does a cache make things faster?

A cache keeps reusable results close to where they are needed. A matching valid entry avoids repeating a slower operation.

FIG. LAB / SOFTWAREAUTOPLAY
Why does a cache make things faster?Original sourceRequestCache keyResponseFast cacheValidity check
01 / 05
Hover or tap to inspect a componentSIMPLIFIED MODEL
01
FOLLOW THE PROCESS

Identify the request

Build a cache key from the relevant inputs. Different inputs must not accidentally share an entry when their results differ.

Read the complete explanation +
  1. Identify the request

    Build a cache key from the relevant inputs. Different inputs must not accidentally share an entry when their results differ.

  2. Check for a usable entry

    Look up the key and check validity. An entry may be absent, expired, or invalidated even if it was cached previously.

  3. Reuse a cache hit

    When a valid matching entry exists, return it. This saves the time and resources needed to repeat the slower operation.

  4. Fetch on a miss

    If there is no usable entry, retrieve or compute the result from the original source. Return it and cache it when permitted.

  5. Keep results appropriate

    Expire or invalidate entries as needed. Caching must balance speed, memory use, and the risk of serving stale data.

About this visual model +

A reference desk makes caching tangible: a small set of copies is kept within reach, while an archive holds the originals. An index card identifies the requested item and a date stamp represents validity.

A conceptual cache. Real eviction rules, consistency models, and expiry policies depend on the application.

  • Request: Identifies the data or operation being requested.
  • Cache key: Selects the exact cached entry. A good key includes every input that changes the result.
  • Fast cache: Holds a limited collection of reusable results.
  • Original source: Supplies a result when the cache cannot satisfy the request.
  • Response: The result returned to the caller.
  • Validity check: Determines whether a cached result is still permitted to be reused.

Further reading: HTTP caching ↗

Includes the current step and explanation
Did this help it click?Ask another question