Most people don't actually understand how Claude's prompt caching works. I didn't either, to be honest, until I sat down and actually looked at my own token reads and writes properly. Turns out I'd potentially been leaving a lot of money on the table, and so has almost everyone else running agents against the Anthropic API.
Here's the bit that matters: Anthropic bills a cached token read at roughly a tenth of the price of a fresh one. Cache writes cost more, about 1.25x, with a five-minute window before they expire (or 2x for an hour). So if your requests keep landing on the same cached prefix, you're paying pennies. If they keep missing it, you're paying extra for nothing. The catch is that a cache hit needs the bytes leading up to the breakpoint to match exactly, byte for byte.
That's a much harder bar than it sounds. In my own setup I found three separate things quietly breaking it. Tool definitions were getting re-serialized in a different key order between runs, so the exact same tools produced different bytes every time. Session-scoped junk - scratchpad paths, session UUIDs - was sitting inside system prompts and invalidating the whole prefix on every single call. And when I had parallel agents firing the same not-yet-cached prefix at the same moment, each one was paying the full write cost instead of one writing it and the rest reading it back cheap.
So I built cache-assembler. It's a small, dependency-free proxy that sits in front of the Anthropic API and fixes all three: it canonicalizes what's safe to canonicalize, places the cache breakpoints where they'll actually get hit, relocates the volatile bytes out of the stable prefix, and puts a write barrier in front of concurrent identical requests so only the first one pays. The one feature that rewrites bytes the model actually sees ships disabled by default - that's not something I'm going to decide for you.
I didn't want to publish this with a made-up number, so before I put it out there I ran a proper controlled experiment against the real API rather than extrapolating from a synthetic test. Same 100-turn conversation, sent twice: once straight to Anthropic, once through the proxy. Direct: $1.33. Proxied: $0.16. That's 8.2x, on the real API, zero errors in either arm.
Getting to that number wasn't clean, and I'm not going to pretend it was. Throwing real traffic at this thing found four genuine bugs that my unit tests had completely missed - an invalid cache-TTL ordering that threw a 400 error, a second one in the mirror direction I only found after the first fix, telemetry silently going blind on compressed responses, and an economics formula that had been inflating every dollar figure I'd reported up to that point. All four are fixed now, with regression tests, and I've written the fixes up honestly in the validation report rather than quietly patching and moving on.
I also ran a comparison I ended up throwing straight in the bin: matching the proxy's cache reuse ratio against my own historical Claude Code sessions. The numbers came back statistically indistinguishable, which sounded interesting for about five minutes until I remembered the two datasets were different projects, different tools, different everything else. It didn't isolate anything, so it's in the report as a documented mistake rather than evidence, because that's the honest way to write it up.
What I can't tell you yet is whether this scales down to a lighter setup the same way. The ceiling on the multiplier tracks how much of your stack is heavy tooling and heavy parallel agent traffic - I've got a lot of both. A single-session user with a small system prompt would plausibly land closer to 2-3x than 8x. Still real money, just a smaller number, and I haven't measured that tier yet.
It's MIT licensed, and the full validation report, raw data, and reproduction scripts are all in the repo. Run the same experiment yourself with your own Anthropic API key - it costs about a pound fifty - and check my numbers rather than taking my word for it.
What does your own cache hit rate actually look like? Most people I've asked have never checked.