Token Efficiency Encyclopedia

Prefix Stability

Build every request so that its cached prefix is byte-identical to the previous one. Prompt Caching is the provider-side mechanism; Prefix Stability is the caller-side discipline that decides whether the mechanism ever produces a hit. A cache can be switched on and still hit 0% of the time if a timestamp sits at the top of the system prompt.

How It Works

A cache read requires an exact byte match of the prefix, on the same model, within the TTL. Any byte that differs invalidates everything after it. So the request is laid out by volatility: the most stable content first, the most volatile last.

  1. Tool definitions (rendered first by the Claude Messages API)
  2. System prompt and static reference context
  3. The growing conversation, with the cache breakpoint moving to its last block

Common Cache Breakers

Techniques

Measuring It

Track cache hit rate (cache_read_input_tokens over total input tokens) per request type. An unexpected drop points to a prefix change; diffing two consecutive requests byte-by-byte finds where they diverged. Claude Console and the cache diagnostics API report miss reasons and the divergence point directly.

Limitations

See Also

Tools