The Curator

Prompt Caching vs. Context Compression vs. RAG: Which Strategy Should Control Your AI Context Costs?

Last updated: 9/12/2026

Back to blog
MM Huq avatarMM Huq 7 min read
Cover image for Prompt Caching vs. Context Compression vs. RAG: Which Strategy Should Control Your AI Context Costs?
AI-assisted, human-reviewed. Drafted with AI research tools from public sources and edited by our team. How we build these →

As AI products accumulate instructions, documents, tool results, and conversation history, context becomes an architectural resource. Sending everything to the model preserves information, but it also consumes computation, increases latency, and can bury the relevant evidence beneath unrelated text.

Three approaches address this pressure: prompt caching reuses computation for repeated prefixes; context compression condenses material before inference; retrieval-augmented generation, or RAG, selects a small body of evidence from a larger corpus. They are often treated as substitutes. In practice, each controls a different form of waste.

The three approaches solve different context problems

ApproachCore mechanismBest atPrimary risk
Prompt cachingReuses model-side processing for an identical or reusable prompt prefixRepeated, stable contextLow reuse when prefixes change
Context compressionTransforms source material into a shorter representationLong histories and verbose intermediate outputDiscarding details needed later
RAGIndexes a corpus and retrieves selected passages for each requestLarge, evolving knowledge collectionsFailing to retrieve the decisive evidence

Prompt caching asks, “Have we processed this text before?” Compression asks, “Can we represent this material more economically?” RAG asks, “Which material belongs in this request at all?” That distinction should govern the design.

Prompt caching: preserve the text, reuse the work

Prompt caching is the least transformative option. The application still sends or references substantial context, and the model still reasons over that context. The efficiency gain comes from avoiding repeated processing of a stable prefix.

Consider a contract-review assistant. Every request may begin with a long system policy, an organization’s negotiation playbook, and a standard clause library. Users then append a particular contract and question. If the stable material occupies the beginning of the prompt, a compatible inference system may reuse its prior computation while processing only the changing suffix.

Where it excels

  • High fidelity: no summarizer decides which details survive.
  • Minimal application logic: the product need not maintain a retrieval index or compressed memory representation.
  • Predictable semantics: the model sees the same source text it would have seen without caching.

Where it breaks down

Cacheability depends on stability. Inserting a timestamp, request identifier, personalized instruction, or reordered document near the start may prevent reuse beyond that point. Even semantically equivalent prefixes can be computationally different if their tokens differ.

Prompt caching also does not resolve context-window pressure. A cached policy manual may be cheaper or faster to process, but it still occupies attention space alongside the user’s task. Caching optimizes repeated computation; it does not make the prompt more selective.

Context compression: trade textual completeness for continuity

Context compression replaces verbose material with a smaller representation. The simplest form is summarization: after a conversation grows beyond a threshold, older turns become a compact account of decisions, preferences, unresolved questions, and commitments.

More structured variants extract entities, constraints, state changes, or tool results. A travel-planning assistant, for example, might reduce twenty turns to: destination, date range, traveler count, accessibility requirements, rejected options, budget posture, and open decisions. That representation is shorter and more useful than a generic prose recap.

The central design choice

Compression can be lossy or selective. Lossy compression produces a general summary. Selective compression preserves fields chosen for the workflow. The latter requires more design work but makes omissions easier to detect.

Imagine a support agent compressing a troubleshooting session. “The customer tried standard fixes” is compact but unsafe: the next agent cannot know whether a factory reset occurred. A structured record listing each attempted action is longer, yet preserves operationally significant detail.

The hidden cost

Compression creates a derived source of truth. Once the original exchange falls outside the active context, the model acts on the summary’s interpretation. Errors can compound when one summary is later summarized again. Strong implementations retain the original record, attach provenance to compressed facts, and regenerate summaries when the schema changes.

RAG: choose evidence rather than carrying history

RAG separates stored knowledge from active context. Documents are divided into retrievable units, represented in an index, and selected in response to a query. The model receives only the passages judged relevant, often with identifiers that permit attribution.

This is the natural architecture for a product answering questions across thousands of policies, manuals, cases, or research notes. It can also respond to changing information without rewriting a static prompt: update the source collection and its index, then retrieve from the revised corpus.

RAG’s difficulty lies before generation. A model cannot reason over evidence that retrieval failed to supply. Vocabulary mismatch, poor chunk boundaries, missing metadata, ambiguous queries, and excessive top results can all degrade the answer.

A worked retrieval example

Suppose an employee asks whether parental leave affects bonus eligibility. Pure similarity search may retrieve the leave policy but miss the compensation policy where eligibility is defined. A stronger pipeline can rewrite the question into separate retrieval intents, search both policy domains, filter by jurisdiction and effective date, then rerank the resulting passages before generation.

This reveals RAG’s real character: it is not merely a database attached to a model. It is an evidence-selection system whose quality depends on corpus design, query interpretation, metadata, ranking, and abstention behavior.

Fidelity, latency, and failure modes

The approaches should be compared by what happens when they fail, not merely by their ideal behavior.

CriterionPrompt cachingContext compressionRAG
Information fidelityHighest when source text is preservedDepends on what compression removesHigh for retrieved passages; absent for missed passages
FreshnessRequires cache invalidation when stable content changesRequires recompression when state changesRequires index updates and version controls
Latency profileCan reduce repeated prefix processingAdds compression work periodicallyAdds retrieval and often reranking on each request
Operational complexityRelatively lowModerate, especially with schemas and provenanceHigh because retrieval is a separate quality surface
Typical failureCache miss or invalid stale prefixImportant detail disappearsRelevant evidence never reaches the model

These failures demand different tests. Prompt caching needs cache-hit diagnostics and invalidation checks. Compression needs fact-retention tests over long sequences. RAG needs retrieval evaluation that asks whether the necessary passage appears before answer quality is measured.

Worked architecture choices

A coding assistant with repository conventions

Use prompt caching for stable coding standards and tool instructions. Use RAG to fetch relevant files, symbols, and documentation for the current task. Compress the interaction history into accepted decisions and outstanding errors. No single approach covers all three forms of context.

A meeting companion

Compression should carry the evolving state: decisions, owners, deadlines, objections, and unresolved items. Prompt caching may help with stable extraction instructions. RAG becomes useful when the assistant must connect the current meeting to earlier transcripts or organizational documents.

A regulated policy adviser

RAG should select versioned, jurisdiction-specific source passages. Prompt caching can preserve a stable reasoning protocol and output schema. Compression should be used cautiously for case history, with links back to original statements. Here, traceability matters more than maximal reduction.

The strongest systems compose the three

A mature context architecture often has layers:

  1. Cache the invariant: stable system instructions, schemas, reference examples, and commonly reused documents.
  2. Compress the accumulated: conversation history, completed tool traces, and resolved workflow state.
  3. Retrieve the contingent: evidence whose relevance depends on the current question.

Ordering matters. Stable cached content belongs early in the prompt so that changing material does not disrupt the reusable prefix. Retrieved passages should carry source and version metadata. Compressed state should distinguish facts, user preferences, model inferences, and unresolved uncertainty rather than blending them into fluent prose.

The application should also retain an escape route. If compressed memory appears insufficient, recover the original transcript. If retrieval confidence is weak, broaden the search or request clarification. If cached instructions change, invalidate the affected prefix deliberately.

Which approach should you choose?

Choose prompt caching when a substantial block of context repeats exactly or predictably across requests, fidelity is important, and the primary problem is repeated processing rather than context size.

Choose context compression when continuity matters across long interactions, much of the history becomes operationally obsolete, and you can define what must survive. Prefer structured state over unconstrained summaries for consequential workflows.

Choose RAG when the relevant evidence sits inside a corpus too large or dynamic to place in every prompt, and when your team can treat retrieval quality as a first-class product discipline.

Combine them when the product has stable rules, accumulating state, and external knowledge. The revealing principle is simple: cache what remains the same, compress what has already happened, and retrieve what matters now.

This post was drafted with AI assistance and reviewed against our editorial policy before publication. Corrections are made at the source, on the page, with the date shown.

Prompt CachingContext CompressionRAGLLM ArchitectureAI Product Design

From our own rounds

Measured on The Curator, from real sessions people played on this site — not a third-party dataset.

Rounds played here
126
Questions per round
1.7
Play a round and add to these numbers
Share this post

Rate this article

No ratings yet

Discussion

Comments are moderated. Read our editorial policy.