Why is Claude prompt caching not saving money in SillyTavern?
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:
enableSystemPromptCache: trueplaces cache breakpoints on the system prompt and character card prefix.cachingAtDepth: 2caches conversation history up to 2 messages before the latest turn. The default value-1disables 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.
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 depth2–4near 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 triggers400rejections on Anthropic Messages endpoints.

