Skip to content

Instantly share code, notes, and snippets.

@karthiks
Last active March 21, 2026 05:32
Show Gist options
  • Select an option

  • Save karthiks/caa563eb6bfbb38751a3e32fb0f41dbf to your computer and use it in GitHub Desktop.

Select an option

Save karthiks/caa563eb6bfbb38751a3e32fb0f41dbf to your computer and use it in GitHub Desktop.
Flowchart - Clearer Visual of the Cache Flow
flowchart TB
    subgraph Request1[Request 1: Cache Write]
        A1[System prompt<br/>CLAUDE.md + Tools] 
        A2[User message 1]
        A3[Cache Storage]
        
        A1 --> A3
        A2 --> B[Process full request]
        A3 --> B
    end
    
    subgraph Request2[Request 2: Cache Hit]
        C1[System prompt<br/>CLAUDE.md + Tools<br/><b>IDENTICAL PREFIX</b>]
        C2[User message 2<br/><i>Only new content</i>]
        C3[(Prompt Cache)]
        
        C1 --> C3
        C3 -->|Cache hit!<br/>$0.30/MTok| D[Process new content only]
        C2 --> D
    end
    
    Request1 -->|Session continues| Request2
    
    style C3 fill:#90EE90,stroke:#228B22,stroke-width:2px
    style C1 fill:#FFE4B5,stroke:#FF8C00,stroke-width:2px
    style C2 fill:#E0E0E0,stroke:#666,stroke-width:2px
Loading

Comments are disabled for this gist.