Knowledgebase

Caching in Front of the Database Print

  • 0

Reducing load.

WHAT CACHING DOES

Stores the result of expensive work so it need not be repeated.

WHAT TO CACHE

Query results that are expensive and rarely change Rendered fragments Computed aggregates Reference data

WHAT NOT TO CACHE

Anything that must be current Data specific to one user, unless keyed properly

WHY THAT SECOND POINT MATTERS

A cache keyed carelessly serves one user's data to another.

WHAT THAT IS

A serious breach, and it has happened to many products.

WHAT TO ALWAYS INCLUDE IN A CACHE KEY

Everything the result depends on, including the user or tenant.

WHAT INVALIDATION MEANS

Removing cached data when the underlying data changes.

WHY IT IS THE HARD PART

Knowing everything a change affects is genuinely difficult.

WHAT THE SIMPLEST APPROACH IS

Short expiry times.

WHY IT WORKS

Staleness is bounded, and no invalidation logic is needed.

WHAT TO MEASURE

Hit rate.

WHAT A LOW RATE MEANS

The cache is not helping and may be costing.

WHAT TO BE CAREFUL WITH

A cache that becomes essential rather than an optimisation.

WHY

Its failure then takes the application down.

WHAT TO TEST

Behaviour with the cache empty or unavailable.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot