LLMs & Generative AI for Practitioners
Back to Prompt Engineering and Patterns

Prompt Caching and Cost Optimization

The single highest-ROI prompt engineering technique in 2026. Cache once, save 90%. FIND_VIDEO: search 'prompt caching anthropic openai cost optimization' — recommended channel: Anthropic / AI Engineer. Aim for 10 min or under.

12 minutesVideo LessonPDF notes
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.
Loading progress...

Key moments

  1. Prompt Caching Economics — Explains the cost structure of paying a 25% write premium for a 90% discount on cache reads.
  2. Large Document Caching — Demonstrates caching a 187k-token book to cut follow-up query latency from 25.4s to 2.38s.
  3. Constraints, Thresholds, and TTL — Outlines the 5-minute sliding TTL, model token minimums, and usage response metadata verification.
  4. Agent Tool Caching — Shows how to attach cache control blocks directly to tool definitions for agent workflows.
  5. Multi-Turn Conversation Caching — Implements a rolling two-point caching loop across sequential user turns in a chat context.
PDF notes

Frequently asked questions

What happens if my prompt is below the model's token threshold?

The API silently bypasses prompt caching and processes all tokens at standard input pricing without throwing an error.

How does the 5-minute Time-to-Live (TTL) work?

It is a sliding window that resets to 5 minutes each time a request successfully reads from that cached prefix.

Can I cache agent tool definitions alongside system prompts?

Yes, adding `cache_control` to tool definitions caches the preceding system instructions and tool schemas together as a prefix.

How do I know if my request hit the cache?

Inspect `response.usage.cache_read_input_tokens`; non-zero values confirm tokens retrieved from cache at the 90% discount.

How was this lesson?

Your feedback helps us refine explanations and catch bugs.