New Tool Radar

AI Concepts

How to Cache a Repeated System Prompt with Claude Prompt Caching

Cache a repeated system prompt with Claude prompt caching so later requests reuse it instead of reprocessing it.

Schematic illustration of cache a repeated system prompt with claude prompt caching: step one mark the stable prefix, step two send the first request, step three read the usage fields.

Prompt caching lets the API reuse the processed prefix of an earlier, identical prompt, so you pay a fraction of the input price for that prefix on later requests. The simplest way to turn it on is automatic caching: a single top-level cache_control field, which places the breakpoint on the last cacheable block and moves it forward as the conversation grows. Use it when the same system prompt or document is sent in many requests.

Prerequisites

  • Access to the Claude API with prompt caching available.
  • A system prompt or document that stays the same across requests.
  • A way to read the response usage fields.

Steps

Step 1: Mark the stable prefix

Add a single top-level cache_control field to the request. The system applies the breakpoint to the last cacheable block, so the stable system prompt and the conversation so far are cached.

Step 2: Send the first request

Send the first request. The prefix is written to the cache once the response begins; the first request pays the write cost, which is more than a plain input.

Step 3: Read the usage fields

On the next request, read the usage fields: cache_read_input_tokens shows the tokens read from cache, and cache_creation_input_tokens shows new writes. A read above zero means the cache is working.

Worked example: Northgate Clinic triage assistant

The fictional Northgate Clinic sends the same 2,000-token triage system prompt in every request, with a short new question each time.

Request System prompt tokens Cache read tokens Cost note
Request 1 2000 0 Writes the cache
Request 2 2000 2000 Reads the cache
Request 3 2000 2000 Reads the cache

Requests 2 and 3 read 2,000 tokens from cache each, so the repeated system prompt is processed once and reused twice.

Expected result. The usage fields show cache reads above zero on the second and later requests, and the stable prefix is the same in each request. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • A cache hit needs an identical prefix; one changed token in the prefix means a miss and full price.
  • The cache has a lifetime; see the TTL guide for the 5-minute and 1-hour options.
  • Output tokens are not affected; caching only changes the input side.

Sources

See all