> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.beatapi.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.beatapi.io/_mcp/server.

# Why is Claude prompt caching not saving money in SillyTavern?

> Fix the three real causes of missed prompt caches in SillyTavern on BeatAPI: disabled config.yaml flags, full-context sliding windows that shift turn 1 out, and dynamic macros in the prefix.

BeatAPI bills cached input below fresh input only when consecutive requests share a byte-identical prefix and arrive before the cache TTL expires. When Claude prompt caching fails to reduce spend in SillyTavern, the cause is one of three client-side behaviors: disabled `config.yaml` flags, a full-context sliding window, or dynamic text inserted above the cache breakpoint.

## 1. Enable Claude caching in SillyTavern's `config.yaml`

SillyTavern disables Claude prompt caching by default. Open SillyTavern's `config.yaml`, set the two Claude cache keys below, and restart SillyTavern so the startup config reloads:

```yaml
claude:
  enableSystemPromptCache: true
  cachingAtDepth: 2
```

* `enableSystemPromptCache: true` places cache breakpoints on the system prompt and character card prefix.
* `cachingAtDepth: 2` caches conversation history up to 2 messages before the latest turn. The default value `-1` disables history caching.

## 2. Full-context sliding window invalidates the cache on every new turn

When a SillyTavern chat hits the configured **Context Size** limit, every new user message drops the oldest message from the front of the prompt. Removing turn 1 shifts every byte that follows turn 1, so the cached prefix misses on every new turn and hits only when you click **Regenerate / Swipe**.

Summarize and trim 25%–50% of the oldest messages before the chat reaches **Context Size**. Freeing that space keeps the prompt prefix stable across the next 15–20 turns. See [Keep long roleplay memory consistent while controlling token cost](/guides/roleplay-long-memory-cache).

## 3. Dynamic text above the cache breakpoint or expired TTL

* **Remove dynamic macros from top blocks**: Macros such as `{{time}}`, `{{date}}`, or lorebook entries injected above the system prompt change the prefix on every turn. Place lorebooks and Author's Notes at depth `2`–`4` near the bottom of history.
* **Check the 5-minute TTL**: Standard prompt caches expire after roughly 5 minutes of inactivity. Pausing for 10 minutes between replies triggers a fresh cache write on the next message.
* **Exclude historical thinking blocks from `cache_control`**: Placing cache markers on prior reasoning blocks triggers `400` rejections on Anthropic Messages endpoints.

## Related

* [Keep long roleplay memory consistent while controlling token cost](/guides/roleplay-long-memory-cache)
* [Cost optimization](/faq/cost-optimization)
* [Back to AI Models questions](/faq/models)