LESSON 107 / 215·2 min readIntermediate

Exact caching, prompt caching, and semantic caching

Should knowConcept lesson
01 Understand02 Recall03 Prepare

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

  1. Define eligible tasks
  2. Build complete cache key
  3. Check freshness/permissions
  4. Reuse or compute
  5. 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.
PAUSE & RECALL

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…

CONNECT IT TO YOUR INTERVIEW

Turn this concept into a clear answer.

Practice this concept
YOUR NEXT STEP

Keep connecting the ideas.

Next lesson: Batch processing, concurrency, rate limits, streaming, and fallback

Adapted from 13_AI.MD · “Exact caching, prompt caching, and semantic caching”. Examples are study fragments; framework behavior can depend on your version.