AWS Cloud Certify · Practice exams

Amazon Bedrock Prompt Caching and Token Accounting

Prompt caching is one of the most testable ways to cut cost and latency. These notes cover what to cache, how checkpoints and the TTL behave, why a cache miss happens and how the token counts in the response add up.

Key points (3)

Prompt caching · Cache the static prefix

Prompt caching reuses a long, repeated prompt prefix to cut latency and input token cost, so put static content first and dynamic content last. Cache checkpoints need a model-specific minimum (512 to 4,096 tokens) and the default 5-minute TTL resets on every hit.

Official source: docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html

Prompt caching · Prefix order and cache misses

Cache checkpoints are processed in the order tools, system, messages, and changing an earlier section invalidates the later ones. Any change to the cached prefix is a cache miss; check cacheReadInputTokens and cacheWriteInputTokens in the response.

Official source: docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html

Prompt caching · Count tokens with caching

With caching on, inputTokens only counts non-cached tokens. Total input tokens = inputTokens + cacheReadInputTokens + cacheWriteInputTokens. Cached reads are billed at the cache-read rate, and prompt caching is not supported with batch inference.

Official source: docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html

Where this fits in the exam

Guides that go deeper

Practice this topic

Answer practice questions, then review your mistakes with spaced repetition.

Start a test

More GenAI Developer study topics