Gemini API Implicit Caching Behavior

Hi everyone,

I have a question about the Behavior of implicit caching in the Gemini API.

Docs

Context / Assumptions
•This question concerns requests made within the same Google Cloud project.
•Two requests with similar prompts are sent in a short time window:
•Request A (from User A)
•Request B (from User B), sent shortly after Request A

Question
Is it possible, due to implicit caching, for the response to Request B to contain string information that exists only in Request A’s prompt (and not in Request B’s prompt)?

Background
The official documentation states: “Try to send requests with similar prefix…” which suggests caching optimization for similar—but not necessarily identical—prefixes. I would like to understand whether such optimization could cause data from Request A (unique to A and absent from B) to surface in the response to Request B under the implicit caching mechanism.

Thank you.

Hi, No, implicit caching cannot leak prompt data between separate requests. “Similar prefix” in our documentation refers to designing prompts that share identical starting text, such as system instructions. The cache only reuses activations for exact matching tokens, and processes unique prompt text in strict isolation. For more details, see the Gemini Context Caching Guide (https://ai.google.dev/gemini-api/docs/caching).

Thank you very much for your response. I understand, and my questions have been resolved.