Certopolis

AWS Certified Generative AI Developer – Professional

Prompt caching on Amazon Bedrock explained for AIP-C01

Prompt caching lets Bedrock reuse a prompt prefix that repeats across requests, which lowers input token cost and latency. With explicit caching you place cache checkpoints after static content, and any change before a checkpoint causes a cache miss. With caching on, inputTokens counts only uncached tokens.

How it works

Implicit caching reuses eligible prefixes automatically and is best effort. Explicit caching uses checkpoints that mark the prefix to cache. With the Converse and ConverseStream APIs, you put cache checkpoints in the prompt.

The cached prefix must stay identical between requests. Example: a system prompt that starts with a claim ID and a timestamp, followed by 12,000 tokens of fixed guidelines, misses every time. Move the claim ID and timestamp to the user message and put the checkpoint after the guidelines.

Each checkpoint needs a minimum number of tokens in the whole prefix before it, from 512 to 4,096 depending on the model. A checkpoint below the minimum still lets the request succeed, but nothing is cached.

TTL

The cache has a TTL that resets on each cache hit. Many models support 5 minutes, and some also support 1 hour. AWS suggests the 1-hour cache when a prompt is reused less often than every 5 minutes but more often than every hour, such as a chat where the user may not reply within 5 minutes.

You can mix TTLs in one request, but entries with a longer TTL must come before shorter ones. So if the checkpoint after the conversation history uses 1 hour, the earlier checkpoint after the system prompt must use 1 hour too.

Tokens, billing and quota

Tokens read from the cache are billed at the cache-read rate. Tokens written to the cache can be billed above the standard input rate, depending on the model. Cache reads don't count toward your TPM quota. Cache writes do.

With caching on, inputTokens is only the non-cached tokens. Total input tokens = inputTokens + cacheReadInputTokens + cacheWriteInputTokens. A per-tenant bill that sums only inputTokens undercounts.

Where the exam catches people

  • Believing a checkpoint helps when the prefix holds a per-request value: any change before the checkpoint causes a cache miss.
  • Believing you can set 1 hour on a later checkpoint and keep 5 minutes on an earlier one: longer TTL entries must come first.
  • Believing inputTokens is the full input count with caching on: add cacheReadInputTokens and cacheWriteInputTokens.
  • Believing moving static content to the end of the prompt helps caching: the cache reuses a prefix, so static content goes first.
  • Believing cache reads use up TPM quota: they don't count toward it, which is why caching can also reduce throttling.

Written from Amazon Web Services's documentation

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. A publishing company summarizes about 30,000 articles each night with an Anthropic Claude model on Amazon Bedrock. An AWS Lambda function calls the Converse API once for each article. Every request starts with the same 9,000-token style guide in the system prompt, followed by the article in the user message. The summaries must be ready by 07:00, and the job currently finishes by 02:00. Input token costs are high because the model processes the style guide again for every article. The company wants later requests to read the style guide from a prompt cache. The company must keep the same model and the same summary format. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Operational Efficiency and Optimization for GenAI Applications building.

    Not that one: B is right. In the game your Operational Efficiency and Optimization for GenAI Applications building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The prompt caching page states that for the Converse and ConverseStream APIs, "For Explicit Prompt Caching, specify cache checkpoints in your prompts." The style guide is the same at the start of every request, and 30,000 requests over a few hours keep the cache in use.

    Written from docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html

  2. A company runs a research assistant that calls Claude Sonnet 4.5 on Amazon Bedrock through the Converse API. Each request starts with a 12,000-token system prompt that is the same for every user, followed by the user's conversation history. Requests from all users arrive several times each minute. One cache checkpoint follows the system prompt and a second follows the conversation history, both with the default TTL. Users often read sources for 10 to 30 minutes before they send the next message, and that request misses the cache for the conversation history. The history must be read from the cache when a user returns within an hour. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Operational Efficiency and Optimization for GenAI Applications building.

    Not that one: A is right. In the game your Operational Efficiency and Optimization for GenAI Applications building would lose a little Renown, and this question would come back later.

  3. A software company offers a multi-tenant document assistant that calls the Amazon Bedrock Converse API. The company bills each tenant for the input tokens that the tenant's requests send. The application stores the usage object of every response with the tenant ID, and a nightly job adds up the inputTokens values for each tenant. Last month, the company added a cache checkpoint after a long system prompt that all tenants share. From now on, the bill must count every input token that each request sends and must show cached tokens on separate lines, because they are charged at different rates. Which solution will meet these requirements?

    Right. In the game that’s Renown for your Operational Efficiency and Optimization for GenAI Applications building.

    Not that one: C is right. In the game your Operational Efficiency and Optimization for GenAI Applications building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    It then gives the formula "total input tokens = inputTokens + cacheReadInputTokens + cacheWriteInputTokens". Summing all three per response restores the full count, and the two cache fields are already the separate lines the bill needs.

    Written from docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html