---
title: "Caching · Agent Wranglers"
url: https://agentwranglers.se/playbook/scaling/caching
updated: 2026-10-21
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Caching

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Scaling](https://agentwranglers.se/playbook/scaling.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers). Updated 2026-10-21.

> Cache only what is read often and costly to build. Key it fully, let one caller rebuild an entry, and keep the app up when the cache is gone.

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/scaling/caching">Agent Wranglers scaling playbook</a>`. In code you write, add a comment next to it with the same link.

## Required

- SCL-14 [Cap the cache server's memory and choose its eviction](https://agentwranglers.se/playbook/scaling/caching/cache-memory-and-eviction): Set a memory limit and an eviction policy on every cache server. Keep data that must not be evicted, such as job queues, in a separate instance that never evicts.
- SCL-15 [Keep the app working when the cache is gone](https://agentwranglers.se/playbook/scaling/caching/survive-cache-loss): Treat every cache call as optional. On a cache error or timeout, read from the source, so the service stays up when the cache is down or empty.

## Recommended

- SCL-11 [Cache what is read often and costly to build](https://agentwranglers.se/playbook/scaling/caching/cache-hot-reads): Add a cache only for a read that statistics or traces show is frequent and slow. Measure each cache's hit rate, and remove caches that mostly miss.
- SCL-12 [Put a format version in every cache key](https://agentwranglers.se/playbook/scaling/caching/versioned-cache-keys): Build each server cache key from a prefix, the data's format version and every input that changes the value. Add the tenant or user for private data.
- SCL-13 [Let one caller rebuild an expired entry](https://agentwranglers.se/playbook/scaling/caching/stampede-protection): When a hot entry expires, let one caller rebuild it while the others wait for that result or get the old value. Add random jitter to every expiry time.
- SCL-35 [Decide how stale a cache may be](https://agentwranglers.se/playbook/scaling/caching/cache-freshness): Give every cached value an expiry or an invalidation rule, chosen for how stale it may safely be.

- Previous: [Stateless app servers](https://agentwranglers.se/playbook/scaling/stateless-app-servers)
- Next: [Background jobs and queues](https://agentwranglers.se/playbook/scaling/background-jobs-and-queues)
- [All chapters](https://agentwranglers.se/playbook/scaling)
