Knowledgebase

Caching API Responses Print

  • 0

Reducing calls.

WHY CACHE

Fewer requests, faster responses, and resilience when the provider is slow.

WHAT TO CACHE

Data that changes rarely Reference data Anything expensive to fetch

WHAT NOT TO CACHE

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

WHY THAT SECOND POINT MATTERS

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

WHAT TO INCLUDE IN THE KEY

Everything affecting the result, including the caller.

WHAT CACHE HEADERS PROVIDE

The provider telling you how long a response remains valid.

WHAT TO RESPECT

Those instructions, where given.

WHAT CONDITIONAL REQUESTS PROVIDE

Asking whether something changed, receiving nothing if not.

HOW

Sending a previously received validator with the request.

WHY THAT HELPS

It saves transfer, though not the round trip.

WHAT EXPIRY TO SET WHERE THE PROVIDER GIVES NONE

Short, and based on how stale you can tolerate.

WHAT TO DO WHEN THE PROVIDER IS UNAVAILABLE

Serve stale data, if that is better than failing.

WHAT TO TELL THE USER

That the data may be out of date.

WHAT TO MONITOR

Hit rate, and whether caching is actually helping.

WHAT TO TEST

Behaviour with the cache empty.


Was this answer helpful?
Back

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


Trustpilot