Skip to main content
AI / MLLLM FundamentalsDiagramIntermediate

Prompt Caching

KO: 프롬프트 캐싱·EN: Prompt Caching·JA: プロンプトキャッシュ

An inference optimization that reuses precomputed KV Cache states for repeated prompt prefixes—such as system prompts, docs, or tool schemas—slashing input costs and TTFT

Table of Contents

Structure Diagram

Cold Prefill vs Prompt Cache Hit Latency
Cache Miss (Cold)3 steps
Cache Hit (Warm)3 steps
STEP 1Prefix Prefill (80K)(72ms)
Quick Answer

What is Prompt Caching?

An inference optimization that reuses precomputed KV Cache states for repeated prompt prefixes—such as system prompts, docs, or tool schemas—slashing input costs and TTFT. It is a core concept in LLM Fundamentals within AI / ML.

Core Principles

During LLM inference, the prefill phase over long prompts is compute-intensive and dominates Time to First Token (TTFT). Prompt Caching preserves the computed Transformer Key-Value (KV) tensors for shared prompt prefixes so subsequent requests starting with the exact same tokens skip redundant prefill computation.

For agentic loops, long documents, and large tool libraries, prompt caching commonly cuts input token costs by 50–90% while dramatically improving responsiveness.

Practical Takeaways

  • Order prompt blocks from static to dynamic: Prefix matching stops at the first differing token. Place System Prompt → Tool Schemas → Static Docs → History → Latest User Turn in strict stability order.
  • Keep volatile metadata out of the prefix: Injecting live timestamps or request IDs at the start invalidates the entire cache; move them to the latest user message.
  • Batch around cache TTLs: Most providers keep cached KV states warm for 5–60 minutes, so grouping related multi-turn or batch requests maximizes hit rates.

Notable Examples

  • Coding Agents: Cache large system instructions, tool schemas, and repo maps across dozens of edit-test iterations.
  • Long-Document Q&A: Pin a 100-page manual or legal contract in the prefix while answering multiple follow-up questions.
  • Multi-Pass Pipelines: Reuse the same cached document prefix to run extraction, summarization, and classification sequentially.