Where a DeepSeek cache hit starts and stops in your prompt

By Christophe Paka · Facts checked on 23 October 2026

Your answer bot sends the same long policy with every customer question. Traffic stays flat, yet the bill climbs. You open the usage block and see prompt_cache_hit_tokens close to zero.

One changing line at the top of a prompt can triple the bill. A DeepSeek cache hit is input DeepSeek has seen before at the start of a recent prompt, and it costs a small part of the full input price. The figure below shows the one rule that decides where the hits end, so you can lay out prompts that keep them.

Two requests share the same stable prefix, a system prompt plus reference docs; a dashed cache boundary splits it from the varying user question, billed as cache hit and cache miss tokens.
Figure 4.3 The prefix cache: everything before the first changed byte can be a cache hit, about a fiftieth of the price on Flash; the rest is a cache miss.
Use this diagram on your site

Free to share in your blog post, docs, course or slides, as long as the credit link stays. Paste the code below where the figure should go.

How to read this figure

  1. Start with Request A. Request A opens with a stable prefix: the system prompt plus reference docs, the same text down to every character on each call. The prefix is the opening part of a prompt. The user's question comes last, in the orange box, and it changes on every call.

  2. Compare Request B with Request A. Request B starts with the same stable prefix. DeepSeek kept it from Request A, so it reuses it from disk instead of reading it again. Only the question differs.

  3. Find the cache boundary. The blue dashed line marks the first changed byte. The match runs from the very first character, and one changed character ends it. Everything left of the line can be a cache hit. Everything right of it is a cache miss.

  4. Read the two bills underneath. Hits are counted in prompt_cache_hit_tokens and cost about a fiftieth of the full input price on Flash. Misses are counted in prompt_cache_miss_tokens at the full input price. Both fields sit in the usage block of every reply.

  5. Work out your hit rate. Your cache hit rate is hits divided by hits plus misses. It is the biggest lever on the bill. A long fixed prefix and a short question give a high rate. The peak clock is the other lever.

Key takeaways

  • Put the fixed text first and the changing question last in every prompt, in the same order every time.
  • Read prompt_cache_hit_tokens after any change to your prompt; a fall toward zero means the prefix broke.
  • Move time stamps and other lines that change on every call below the fixed text, or drop them.

Worked example: one policy, two prompt layouts

Juniper Books runs an answer bot. Each call sends a 6,000 token policy and a 200 token question. The policy is 97% of each call's input.

  1. Policy first, question last. Every call starts with the same 6,000 tokens, so they can be cache hits. Round down to a 95% hit rate, since DeepSeek promises no hit.
  2. Now stamp the current time on the very first line. The time changes on every call, so the match ends at the first character.
  3. Hits fall toward zero. For illustration, assume 40% still hit.
  4. Price both months with the chapter's numbers. On Flash at peak, the policy first month costs about $4.40 and the time stamp month about $13.42. One time stamp triples the bill.

Result: Move the time stamp below the policy, or drop it. The symptom to watch for: the bill climbs while traffic stays flat, and prompt_cache_hit_tokens falls toward zero.

Questions readers ask

Why is my DeepSeek bill higher than I expected?

Usually the cache. The bill depends on how much input lands as cache hits. Read prompt_cache_hit_tokens and prompt_cache_miss_tokens in the usage block. A changing line at the top of the prompt, such as a time stamp, turns most of your input into misses at the full price.

Can I turn the DeepSeek cache off?

No. The prefix cache is on for everyone, with no switch. So DeepSeek keeps your prompt openings on its servers, usually for hours to days after their last use, as its Context Caching docs say. If your app serves many people, your code can send a user_id, an ID for each end user, and the cache keeps each user's text apart. The docs say nothing about sharing between accounts. So keep personal data out of prompts.

Is there a minimum prompt size for a cache hit?

DeepSeek does not publish one. A hit needs a whole saved chunk to match, and chunks end where each user message and each reply end. Saved copies are built within seconds, but DeepSeek promises no hit. At one call every few hours, expect fewer hits.

Sources: DeepSeek API Docs, Context Caching; DeepSeek API Docs, Models and Pricing.

This figure is from DeepSeek Made Crystal Clear, chapter 4.

The chapter builds the idea step by step, with recipes you can follow, a Try it to check yourself, and every source.

Get the book

All diagrams