Part 3 · From Working Demo to Useful Product

The Subtle Relationship Between Prompts and Caching

Change one character in System Prompt and the entire KV Cache is invalidated. Minimizing accidental cost

THE QUESTION THIS PAGE ANSWERS

ANSWER FIRST

What is the key idea behind “The Subtle Relationship Between Prompts and Caching”?

Change one character in System Prompt and the entire KV Cache is invalidated. Minimizing accidental cost

DECISION RULE

Make the claim earn its place. Use this page as a decision aid, not a definition to memorize. Connect the idea to one real task, one observable result, and one failure that would change your mind.

TRY NEXT

Write one question you could answer with evidence after trying this idea.

WATCH FOR

A conclusion that sounds complete but leaves the key assumption untested.

Changed fingerprint = Cache invalidated

Every request, the system computes a fingerprint (hash) of the System Prompt

System: You are an assistant. Current time: 14:35:22
a3f7c2
MISS
System: You are an assistant. Current time: 14:35:23
b8e1d9
MISS
System: You are an assistant. Current time: 14:35:24
c4a2f6
MISS

Different time each second → different fingerprint → cache never hits → recomputed every time → costs double.
This isn't just a timestamp issue: any dynamic content injected into the System Prompt has the same effect.

Skill injection method also affects caching
Inject Skill into System
[System] You are an AI assistant... [Current Skill: Content Creation] Trigger: Help me write... Steps: 1. Confirm requirements... --- [User] Help me write an article

Switching Skills changes System → cache invalidated

~20%
Skill appended as a separate message
[System] You are an AI assistant... --- [Assistant/Skill message] Current Skill: Content Creation Steps: 1. Confirm requirements... --- [User] Help me write an article

System never changes → prefix cache always hits

~90%
Simulation: Cache Performance Across 10 Requests

Cache Hit Simulator

Assume 3 out of 10 requests switch to a different Skill. Observe the cache difference between the two injection approaches:

Hit rate:
The rule of KV Cache is simple: same prefix = hit. So don't touch the prefix. Put everything that might change (Skills, context, timestamps) after the System Prompt, and keep the prefix permanently stable.

Why “Changed fingerprint = Cache invalidated” depends on the operation

“Different time each second → different fingerprint → cache never hits → recomputed every time → costs double.” makes the structure concrete. The useful comparison is not which name sounds more advanced, but how the data is arranged and how far the most common operation has to travel.

Read a structure through access and change

“Switching Skills changes System → cache invalidated” exposes a trade-off that is easy to miss: reading by position, looking up by key, adding at either end, inserting in the middle, and traversing relationships do not favor the same organization. A structure that is fast for one operation is not automatically fast for all of them.

Count scale and update frequency together

Use “Assume 3 out of 10 requests switch to a different Skill.” as a boundary check. Write down the data size, the dominant operation, and the latency you can accept before deciding whether an AI-generated structure actually fits.

From “Changed fingerprint = Cache invalidated” to “Skill injection method also affects caching”

“Changed fingerprint = Cache invalidated” grounds the problem in “Different time each second → different fingerprint → cache never hits → recomputed every time → costs double. This isn't just a timestamp issue: any dynamic content injected into the System Prompt has the same…”. “Skill injection method also affects caching” then moves it toward “Switching Skills changes System → cache invalidated”. Together, they show that the lesson is not just a conclusion to remember, but a claim with conditions.

Carry the judgment into the next situation

When you meet a new data structure, do not begin by memorizing its definition. Write down the most frequent operation, estimate scale and update behavior, and check whether the structure satisfies all three conditions.

  • “Changed fingerprint = Cache invalidated”: Different time each second → different fingerprint → cache never hits → recomputed every time → costs double. This isn't just a timestamp issue: any dynamic content injected into the System Prompt has the same…
  • “Skill injection method also affects caching”: Switching Skills changes System → cache invalidated
  • “The closing point”: System never changes → prefix cache always hits

The final “The closing point” brings the discussion to “System never changes → prefix cache always hits”. The useful thing to carry forward is knowing which judgments must be revisited when input, scale, or risk changes.

Mark as learned Your reading progress updates automatically
← PreviousNext →

Keep reading

The next useful article in the thread.

ARTICLE DISCUSSION

Leave one useful thought here.

Keep the idea that clicked, the question that stayed open, or a small note for the next learner.

Discussing The Subtle Relationship Between Prompts and Caching From Working Demo to Useful Product
3discussionsArticle discussion · synced with the Circle
View in the learning circle
AM
Asha MorganContent editor
INSIGHTField note

I turned one judgment from this article into a small experiment I could run today. Knowing what to observe next is more useful than simply remembering the conclusion.

ARTICLE DISCUSSION7 helpful
LH
Lin HarperIndie developer
INSIGHTInsight

After reading this, I first looked for the conditions behind the idea instead of copying the method into a project. That order made the later trade-offs much clearer.

ARTICLE DISCUSSION5 helpful
KM
Kiki MooreProduct operations
QUESTIONQuestion

When this judgment reaches real work, which constraint should be added first? I am curious which step matters most between reading and the first practical attempt.

ARTICLE DISCUSSION4 helpful