All challenges
PerformanceIntermediate
Prompt cache invalidation cascade
After deploying an analytics commit that injected the current server UTC timestamp into line 2 of a system prompt, your team's LLM API costs surge 4x overnight and P95 latency jumps from 420ms to 3.4s on Claude and OpenAI endpoints. The workload is 95% repetitive customer-support classification over a 12,000-token enterprise taxonomy prompt.
Symptoms
- Cache hit rate dropped from 94% to 0% immediately following deployment of the timestamp change
- P95 request latency increased from 420ms to 3,450ms (~8x regression)
- Daily API billing surged ~4x despite steady request volume (~150k calls/day)
- KV cache prefix metrics in provider console show 100% cache misses on the 12,000-token system preamble
Evidence
Prompt template diff
// System prompt assembly
const systemPrompt = [
"You are the enterprise tier-1 support classifier and policy dispatcher.",
+ `Current system time (UTC): ${new Date().toISOString()}`,
"Follow these 48 classification rules and routing taxonomies strictly:",
TAXONOMY_GUIDELINES_V4, // 12,400 tokens of static business policy
].join("\n\n");Provider API metrics (Datadog dashboard)
Before deployment: - Prompt tokens: 12,550 total (12,400 cached, 150 uncached) - Cache read input tokens: 12,400 ($0.375 / Mtok) - Cache creation input tokens: 0 - TTFT (Time to First Token): 180ms - Total request latency: 410ms After deployment: - Prompt tokens: 12,550 total (0 cached, 12,550 uncached) - Cache creation input tokens: 12,550 ($3.75 / Mtok) - Cache read input tokens: 0 - TTFT: 2,850ms - Total request latency: 3,420ms
Provider cache protocol requirements
Prefix caching rules (Anthropic prompt caching and OpenAI prefix caching): 1. Cache lookup matches token prefixes strictly from byte 0 forward. 2. Any variation in token sequence busts cache hits for all subsequent tokens. 3. Dynamic variables (timestamps, UUIDs, per-user identifiers) invalidate all downstream cached blocks.
Tasks
- 1Identify why injecting the timestamp at line 2 causes a 0% cache hit rate
- 2Explain why latency increased ~8x alongside the billing spike
- 3Provide the corrected prompt structure preserving prompt caching benefits while still supplying current time