By NHI Mgmt Group Editorial TeamBased on ngrok: “Prompt caching: 10x cheaper LLM tokens, but how?” (December 16, 2025)

TL;DR: Prompt caching in LLMs reuses key and value tensors, not model outputs, which cuts latency and lowers token costs for long prompts, according to ngrok's explanation of OpenAI and Anthropic API behaviour. That makes caching a performance control with governance implications for AI systems, especially where prompt reuse, access patterns, and sensitive context need tighter oversight.


At a glance

What this is: This is an explanation of KV caching in LLMs and the key finding is that providers cache internal key and value tensors to accelerate repeated or partially repeated prompts.

Why it matters: It matters because AI teams need to understand what is being reused, where latency and cost gains come from, and how cached context changes governance over sensitive prompts and access patterns.

By the numbers:

  • Cached input tokens are 10x cheaper in dollars per token than regular input tokens for both OpenAI and Anthropic’s APIs.
  • Anthropic claim that prompt caching can reduce latency by up to 85% for long prompts.

Context

KV caching is a performance mechanism in transformer-based LLMs that stores intermediate representations so repeated prompt prefixes do not have to be recalculated. The security relevance is that this optimisation changes how AI systems handle repeated context, which matters when prompts contain sensitive instructions, customer data, or policy-relevant material.

For AI security teams, the issue is not whether caching works but how it interacts with access control, observability, and data handling decisions. Once providers reuse internal state across requests, practitioners need to think about prompt reuse, cache scope, and whether performance optimisations are creating invisible governance assumptions.

In practical terms, the article treats caching as a model-internal efficiency feature with operational consequences rather than a new control boundary. That makes it relevant to teams governing LLM usage, especially where prompt histories or delegated access are part of the system design.


Key questions

Q: How should security teams govern prompt caching in LLM applications?

A: Treat prompt caching as part of the AI control surface, not just a cost-saving optimisation. Define which prompts may be cached, how long cached state can persist, and which workloads require isolation because they carry confidential or regulated context. Governance should cover provider behaviour, retention, and visibility, not only developer convenience.

Q: Why can cached prompts create governance risk even when outputs are not reused?

A: Because the reused object is internal model state, not the answer text. That state can carry forward context that affects later inference, so teams need rules for what may persist between requests, who can send it, and how long the system may keep it available for reuse.

Q: How do you know if an LLM cache policy is actually working?

A: Look for predictable cache-hit behaviour, clear retention windows, and consistent handling of sensitive prefixes across identical workflows. If latency and cost vary unpredictably, or if teams cannot explain which context was reused, the cache policy is probably under-specified for operational governance.

Q: What is the difference between prompt caching and response caching in LLMs?

A: Prompt caching reuses internal computation from the input side, especially the key and value tensors used by attention. Response caching would store a finished answer and serve it again. The security and governance implications differ because prompt caching changes inference efficiency, while response caching changes what content is replayed.


Technical breakdown

What KV caching stores inside the transformer

KV caching stores the key and value matrices produced by the attention layers after a prompt prefix has been processed. In a transformer, attention compares the current token against prior tokens using keys, then builds the next representation from the matched values. Recomputing those matrices for every new token is expensive, so caching preserves the useful intermediate state and reuses it when the prompt prefix matches. That is why the optimisation speeds up long-context inference without changing the model output itself. The cached material is not the answer text, but the internal state that helps the model decide what matters next.

Practical implication: Treat cache reuse as a model-efficiency layer, not as a content store, when assessing what data exposure actually changes.

Why cache hits change latency and cost, not the model’s behaviour

The main effect of KV caching is to shorten time-to-first-token and reduce compute for repeated context. The model still generates fresh outputs token by token, but it starts from precomputed attention state instead of rebuilding that state from scratch. That is why the same prompt can produce different responses while still showing cached input tokens. Provider behaviour also matters: one service may auto-route to cached state, while another may let the caller choose cache duration and placement. For governance, that means performance predictability and cache policy are part of the system design, not just a tuning detail.

Practical implication: Separate response determinism from cache reuse so teams do not mistake repeated context for repeated outputs.

What AI security teams should watch in cached prompt flows

KV caching creates an operational trust assumption: the system must know exactly which prefix is safe to reuse and for how long. That can become important when prompts include sensitive instructions, regulated content, or context that should not survive beyond a task boundary. Caching does not itself expose secrets, but it can extend the lifetime of internal state that security teams may not be logging or reviewing. The governance question is therefore about prompt scope, cache boundaries, and whether access reviews and audit trails still reflect how the model is actually being used.

Practical implication: Define cache boundaries and retention rules wherever prompts can carry sensitive or policy-bound context.


NHI Mgmt Group analysis

KV caching is a governance issue as much as a performance feature. Once internal model state can be reused across requests, AI teams are no longer dealing with a single prompt-response event. They are managing a short-lived but meaningful inference context that may outlast the user interaction that created it. For practitioners, that means cache scope, visibility, and expiry deserve the same attention as prompt logging and API permissions.

Performance gains can hide control assumptions. A 10x input-token discount and large latency reductions are operationally attractive, but they can also make teams accept opaque provider behaviour without asking what state persists between requests. The important question is not whether the cache is safe in isolation, but whether the surrounding governance model still matches how the system actually processes sensitive inputs. Teams should treat hidden optimisation layers as part of the trust boundary.

Prompt reuse introduces a short-lived identity and context problem. The article makes clear that the model is not reusing outputs, only cached internal tensors, which means the risk is not message replay but reused computational context. That distinction matters for AI governance because access, review, and retention controls often assume the prompt is the whole unit of analysis. Practitioners should govern the lifecycle of prompt context, not just the prompt text.

KV cache policy belongs in AI risk management, not just engineering tuning. Different provider behaviours around automatic routing, cache duration, and partial-prefix reuse can materially change operational consistency. That is a programme issue, not merely a developer preference. Security and AI governance teams should treat cache behaviour as a documented design choice, with clear rules for sensitive workloads and predictable handling of reused context.

Prompt caching surfaces a named concept: inference-state reuse. This is the operational pattern where an LLM reuses internal attention state from prior tokens instead of recomputing it. The concept matters because it moves oversight from raw prompts to the lifecycle of model state, which is where performance and governance now intersect. Practitioners should account for inference-state reuse in control design and vendor evaluation.

From our research library:

What this signals

Inference-state reuse is the right lens for cached prompts because the control problem is no longer only about prompt text. Teams need to know how long cached model state survives, which workloads can reuse it, and whether that reuse is compatible with the sensitivity of the input.

AI teams should expect more pressure to document cache policy as part of model governance, especially where prompt prefixes contain policy, customer, or operational context. Performance gains are real, but they do not remove the need to prove that reused context stays inside an agreed boundary.

According to the State of Secrets Sprawl 2026, AI-related credential leaks surged 81.5% year-over-year in 2025, with the surrounding AI infrastructure leaking 5x faster than core LLM providers. That broader pattern shows why the controls around AI systems matter as much as the model itself.


For practitioners

  • Map cache boundaries to sensitive prompt classes Classify which prompt prefixes may be reused, how long they remain eligible for cache hits, and which workloads must never share cached context.
  • Document provider cache behaviour in AI risk reviews Record whether caching is automatic or caller-controlled, whether partial-prefix reuse occurs, and how predictable cache hits need to be for each workload.
  • Align prompt handling with short-lived context Treat prompts containing regulated, confidential, or policy-bound material as ephemeral operational context and define when that context expires for governance purposes.
  • Separate performance tuning from access control Review whether faster inference is masking weak oversight over who can submit prompts, which prefixes are cacheable, and which sessions should be isolated.

Key takeaways

  • KV caching improves LLM performance by reusing internal attention state, but it also widens the governance questions around prompt scope and context persistence.
  • The article shows that cached input tokens are cheaper and faster because providers reuse key and value tensors, not completed answers.
  • AI teams should define cache boundaries, retention rules, and visibility requirements before treating prompt reuse as a default optimisation.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 addresses the attack surface, NIST AI RMF, NIST AI 600-1 and NIST CSF 2.0 set the technical controls, and ISO/IEC 42001:2023 defines the regulatory obligations.

FrameworkControl / ReferenceRelevance
NIST AI RMFGOVERN — AI Governance and AccountabilityPrompt cache policy is a governance decision about model-state reuse and oversight.
Recommendation — Define cache ownership, retention, and approval rules under AI governance before deploying LLM workloads.
NIST AI 600-1GenAI ProfileThe article concerns generative AI inference behaviour and operational controls around reuse.
Recommendation — Apply GenAI profile guidance to document how prompt reuse, latency, and context handling are controlled.
ISO/IEC 42001:2023AI management systemCache behaviour is an AI management concern because it affects process control and accountability.
Recommendation — Record prompt caching as a managed AI system activity with defined roles, controls, and review points.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsCache reuse should be constrained by who may submit prompts and which contexts are eligible for reuse.
Recommendation — Limit prompt submission and cache eligibility through explicit authorisation rules for sensitive AI workloads.
OWASP Agentic AI Top 10ASI03 — Identity & Privilege AbuseWhile not an agent breach, the article’s governance angle concerns reuse of authorised model context and privilege boundaries.
Recommendation — Treat cached model context as part of the system’s effective privilege surface and control its reuse carefully.

Key terms

  • Kv Caching: KV caching is an LLM inference optimisation that reuses key and value tensors computed from earlier prompt tokens. It reduces repeated attention work for long prompts, improving latency and cost efficiency without changing the model’s output logic.
  • Attention Mechanism: An attention mechanism helps a model focus on the most relevant parts of a sequence when producing an output. It assigns relationships between words or tokens so the model can preserve context, handle long inputs more effectively, and reduce the forgetting limits common in recurrent networks.
  • State Inference: State inference is the process of reconstructing a random number generator’s internal state from observed outputs. Once enough values are exposed, an attacker may predict future numbers and sometimes recover past ones. This is especially dangerous when weak generators are used for security-critical application logic.
  • Prompt Prefix Reuse: Prompt prefix reuse is the practice of reusing cached computation for the beginning of a prompt when a later request starts with the same or similar text. It can save time and cost, but security teams need to know which prefixes are eligible and whether the reused context is safe for each workload.

Deepen your knowledge

The NHI Foundation Level course, the industry's only accredited NHI security programme, covers NHI governance, workload identity, and secrets management through a practical control lens. It helps security and platform teams connect identity decisions to the way modern systems actually operate.
NHIMG Editorial Note
Published by the NHIMG editorial team on August 19, 2026.
Updated on October 12, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org