Exact caching, prompt caching, and semantic caching
Words made simple
A few useful meanings before you read the explanation.
- Caching
- Keeping a result so it can be reused instead of calculated or fetched again. Cached data needs expiry and access controls appropriate to its use.
- Authorization
- Checking what that identity is allowed to read or do. Being logged in does not grant access to every record.
- Tenant
- A customer or organization whose data must stay separate from other customers in a shared application.
More words from this lesson
- Dependency
- A library or package that your application relies on. Compatible versions help the application run as expected.
Overview
- Exact caching reuses results for the same normalized request and dependencies.
- Provider prompt caching can reduce processing/billing for supported repeated prefixes.
- Semantic caching reuses results for similar meanings, which is more risky because similar requests may require different answers.
Why this matters
Repeated public or stable knowledge requests can avoid duplicate work.
An everyday example
Reuse an approved answer to the same question, but do not reuse one customer's claim status for another customer.
A technical example
Cache a policy answer under tenant, authorization scope, policy version, question, model, and prompt version.
How it works
- Define eligible tasks
- Build complete cache key
- Check freshness/permissions
- Reuse or compute
- Invalidate on source/policy change.
Architecture and flow
Authorized request + source versions → cache lookup → valid hit or model call.
The insurance assistant example
Cache public policy FAQs; avoid semantic reuse for personalized coverage, payouts, or claim status.
When to use it
Stable nonpersonalized content and measured repeated workloads.
When to avoid it
Similar wording is insufficient when tenant, date, policy, or authorization differs.
Interview answer
“I cache only when identity scope, dependencies, and freshness make reuse safe. Semantic caching needs stricter eligibility than exact caching.”
Benefits, trade-offs, and production considerations
- Include corpus/ACL versions and retention.
- Invalidate on revocation and deletion.
- A cache can preserve an injected or incorrect answer, so validate before writing and monitor hit quality.
Can you explain it without the notes?
Exact caching, prompt caching, and semantic caching
Use your own words. Explain an example and one limitation before checking the explanation.
Check your explanation
Exact caching reuses results for the same normalized request and dependencies. Provider prompt caching can reduce processing/billing for supported repeated prefixes. Semantic caching reuses results for similar meanings, which is more risky because similar…
Turn this concept into a clear answer.
Practice this conceptKeep connecting the ideas.
Next lesson: Batch processing, concurrency, rate limits, streaming, and fallbackAdapted from 13_AI.MD · “Exact caching, prompt caching, and semantic caching”. Examples are study fragments; framework behavior can depend on your version.