Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesHow do you use prompt caching with Claude in Node.js? Mark the end of a large, reusable prompt section with a cache breakpoint, then send later requests with that same prefix. Claude can reuse the processed prefix rather than treating it as entirely new input, which can reduce repeated input costs and improve time to first token for long context. Savings and speed are not automatic: the prompt must meet the model’s minimum cacheable length, the reusable prefix must stay unchanged, and the cache must still be within its time to live (TTL).
What Claude prompt caching does
Prompt caching lets Claude reuse eligible prompt content processed in an earlier API call. Anthropic describes it as reducing costs and latency by reusing previously processed portions of a prompt across API calls. See Anthropic’s Prompt caching documentation.
As an Amazon Associate I earn from qualifying purchases.
It is most useful when repeated requests share substantial context: system instructions, tool definitions, examples, a long document, or a conversation history. A cache breakpoint marks the end of the portion Claude may reuse. New user-specific text after that point can change from call to call without changing the cached prefix.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Caching changes the treatment of repeated input; it does not make an entire request free. The first cache write has a premium, newly added input is still processed, and generated output is still billed under the applicable model pricing.
#1 Best Overall
Set up caching in a Node.js request
The official TypeScript SDK is distributed as @anthropic-ai/sdk and uses the Messages API. Its repository lists Node.js 20 LTS or later among supported runtimes. Check the SDK repository for current setup details and model availability. The example below shows the shape of a request with an explicit breakpoint; replace the model ID with one currently available to your account.
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const response = await client.messages.create({
model: "CURRENT_CLAUDE_MODEL_ID",
max_tokens: 1024,
system: [
{
type: "text",
text: "Your stable, reusable system instructions go here.",
cache_control: { type: "ephemeral" },
},
],
messages: [
{ role: "user", content: "A request-specific question goes here." },
],
});
console.log(response.usage);
This places the breakpoint after the stable system text. In a real application, put the substantial shared material—such as document context or examples—before the breakpoint, and request-specific content after it.
Rank #2
Automatic caching or explicit breakpoints?
Anthropic documents two approaches. Automatic caching uses a top-level cache_control: { type: "ephemeral" } setting so the system manages a breakpoint as a conversation grows. Anthropic recommends it as a starting point for most use cases. Explicit block-level breakpoints give more control when prompt sections change at different rates. Consult the current prompt-caching guide for supported request shapes.
One platform-specific exception matters: on the legacy Amazon Bedrock integration for Opus 4.6 and earlier, Anthropic documents that top-level automatic caching is not supported; use explicit block-level breakpoints there.
Rank #3
Put the breakpoint after stable context
A cache entry represents the prompt prefix through a breakpoint. If any content at or before that breakpoint changes, the prefix changes and the previous entry may not be reusable. For example, placing a breakpoint after a changing user question makes that question part of the prefix. Place it earlier, after the shared instructions and context, instead.
- Identify reusable content. Find the instructions, tools, examples, documents, or history that are identical across calls.
- Order the request. Put stable material before per-request text.
- Mark the boundary. Add an explicit breakpoint to the last stable content block, or use automatic caching where supported.
- Keep cache-relevant settings consistent. Changes to tool choice, whether images are present, thinking configuration, or output effort can invalidate a hit. Check Anthropic’s documentation for the current cache-key and ordering rules.
- Confirm eligibility. The minimum cacheable prompt length varies by model; Anthropic lists thresholds ranging from 512 to 4,096 tokens across active models. Verify the target model’s current threshold in the documentation.
Anthropic allows up to four cache breakpoints. Automatic caching follows the same minimum-token thresholds, ordering requirements, and lookback behavior as explicit breakpoints.
Rank #4
Choose a cache lifetime based on request gaps
Anthropic documents a default five-minute cache lifetime and an optional one-hour lifetime. The TTL options behave the same for latency; the one-hour option is useful when a repeat request may arrive after five minutes but within an hour. A five-minute cache can be refreshed within its active period without an additional write premium. Anthropic also says cache hits are not deducted against the rate limit. These details and availability can change, so check the current prompt-caching guide.
| TTL option | When it fits | Standard pricing multiplier |
|---|---|---|
| 5 minutes (default) | Repeated requests are likely to arrive within five minutes. | Cache write: 1.25× base input price; cache read: 0.1× base input price. |
| 1 hour | Follow-up requests may arrive more than five minutes later but within an hour. | Cache write: 2× base input price; cache read: 0.1× base input price. |
These are Anthropic’s standard multipliers, published in its pricing documentation as of October 2026, relative to the model’s base input price. Some models have different multipliers; confirm the live pricing table for the model you use.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Estimate whether caching is worth it
Under Anthropic’s standard multipliers, a five-minute cache pays off after one cache read, and a one-hour cache after two, compared with repeatedly paying the base input price for the same eligible prefix. That is Anthropic’s input-cost break-even guidance, not a guarantee of overall savings for every workload.
Your actual bill depends on the model’s input price, how much prompt content is eligible, how often requests repeat within the TTL, whether calls register cache reads, and how much new input and output each request adds. The initial write costs more than base input, so caching a short prompt or a prefix that rarely repeats may not help. Anthropic’s pricing page is the reference for current model rates and modifiers.
Verify cache writes and reads in the response
Inspect the response’s usage object. Anthropic documents two useful fields:
cache_creation_input_tokensindicates input tokens written to the cache.cache_read_input_tokensindicates input tokens read from the cache.
Compare a first request with a later request using the same model, stable prefix, and cache-relevant settings. A write on the first call and a read on a repeat call are evidence that caching is being used. If the read field is zero, check that the prefix is unchanged, the prompt clears that model’s threshold, the breakpoint is placed correctly, the TTL has not expired, and relevant tools, image presence, thinking settings, and output effort remain consistent.
There is no universal latency or savings percentage: the result depends on the application’s prompt size and request pattern. Long documents generally see improved time to first token according to Anthropic, but measure your own workload before assuming a particular improvement.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




