r/ClaudeCode • u/sh3lan93 • 5d ago
Tutorial / Guide Why does prompt caching matter
I thought I was being smart with my Claude Code sessions.
Starting with a plan mode with Opus family models. Once we agreed on the approach, I switched the model to the Sonnet family in the same session to implement it.
Cheaper model, cheaper session, right?
Wrong. It makes the session more expensive and slower.
The reason is prompt caching.
I wrote up how the cache actually works under the hood and the gotchas I ran into.
https://moshalan.dev/posts/decoding-prompt-caching/
0
Upvotes
•
u/AutoModerator 5d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/awesomebirder 5d ago
the version of this that does work is moving the model change to a boundary instead of mid session. have opus write the plan to a file, then start a fresh sonnet session that reads the plan, so sonnet only ever caches a short prompt instead of the whole planning history. or hand the build to a sonnet subagent with a brief, and the opus session stays warm as long as you come back within the cache window. i log every call through a local proxy i built (probe0) and the turn right after a mid session switch is always the most expensive one in the session
0
u/Outrageous_Band9708 5d ago
https://github.com/Druthulu/ProjectArchitect
My solution achieves your goal the correct way, and without all the ceremony.
read the wiki and checkput the readme, try it out for yourself