Knowledgebase

Caching Strategies Print

  • webdevelopment, caching, database, troubleshooting, guide, howto, solution, zillionkinghost
  • 0

Avoiding repeated work.

WHERE CACHING HAPPENS

In the browser At a delivery network At a reverse proxy In the application In the database layer

WHAT TO CACHE

Expensive computations Repeated identical queries External responses that change rarely Static assets

WHAT NOT TO CACHE

Personal data, in a shared cache Anything that must always be current

WHAT THE HARD PROBLEM IS

Knowing when to invalidate.

WHAT TO DECIDE FOR EACH

How stale it may be What causes it to be cleared

WHAT TO USE FOR STATIC ASSETS

Long cache durations, with a version in the filename.

WHY

The content at a given address never changes, so it can be cached indefinitely, and a change produces a new address.

WHAT THAT SOLVES

Changes appearing immediately without disabling caching.

WHAT TO BE CAREFUL WITH

Caching authenticated responses Cache warming on deployment Cached errors

THAT LAST ONE

Caching a failed response serves the failure to everyone.

WHAT TO MEASURE

Hit rate, and whether it actually reduced load.


Was this answer helpful?
Back

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


Trustpilot