IntermediateAbout 14 min

    Prompt Caching

    Read the full article on Substack

    6 min read.

    Simulate API calls with and without prefix caching, compare provider pricing, and learn how to structure prompts for maximum cache hits — the cheapest performance optimisation in LLM serving.

    Think of it this way: Prompt caching keeps a popular book open on a bookstand. Instead of pulling it off the shelf and flipping to page 200 every time a customer asks about page 201, you read from where you left off — nearly free.

    System
    Tools
    Examples
    RAG
    History
    Query
    Stable prefix: 2,600 tokensChanges each call: 3,500 tokens

    Turn caching on, then send a few calls.

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Lay out a cacheable prompt

    Sequence

    Order the prompt so the cache actually hits.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    5 pieces left to place

    Quiz

    20 questions
    Question 1 of 20
    Score: 0

    What does prompt caching actually store on the server?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going