hackhaton-space-stackHackhaton Space Stack
AcademyBuilder
Get Started
All terms
The Basics
  • Stack
  • Frontend & Backend
  • CLI
  • Monorepo
  • Server
  • Localhost
How AI Works
  • Context Window
  • Hallucination
  • Token
  • Prompt Caching
  • Session
  • Compaction
  • Embedding
  • Vector Database
  • RAG
  • Fine-tuning
  • Temperature
  • Inference
  • Reasoning
  • Multimodal
Building With AI
  • Agent
  • MCP
  • System Prompt
  • Skill
  • CLAUDE.md
  • Slash Command
  • Harness
  • Computer Use
  • Agents SDK
  • Voice Agents
  • OAuth
  • Vibe Coding
  • Permission Scope
  • Tool Calling
  • Prompt Injection
  • Eval
  • Guardrails
  • Sandbox
  • Progressive Disclosure
Code & Collaboration
  • Git
  • Commit
  • Branch
  • GitHub
  • Pull Request
  • Open Source
  • Markdown
  • Dependency
  • Merge
  • Fork
APIs & Connections
  • API
  • Auth
  • Database
  • ORM
  • SDK
  • Webhook
  • Endpoint
  • REST
  • HTTP Methods
  • Env File
  • Schema
  • JSON
  • YAML
  • Secret
  • Rate Limit
  • CORS
  • Cookie
  • Encryption
Shipping & Running
  • Deploy
  • Headless
  • Cron
  • DNS
  • CDN
  • Object Storage
  • Serverless
  • Edge
  • Worker
  • Runtime
  • Process
  • Daemon
  • Queue
  • Job
  • State
  • Cache
  • SSH
  • Build
  • Staging
  • Rollback
  • Docker
  • Feature Flag
  • Test
  • CI/CD
  • The Cloud
Debugging & Errors
  • Trace
  • Type Error
  • Stack Trace
  • Log
  • Bug
  • Patch
  • Latency
How Developers Think
  • DRY
  • YAGNI
  • KISS
  • Refactoring
  • Technical Debt
  • Async
← All terms

Type-safe, modern TypeScript scaffolding for full-stack web development

ThreadsGitHub

Info

  • Academy
  • Docs

Legal

  • Terms of Service
  • Privacy Policy

© 2026 Dzulhelmy Nazri

How AI Works

$defineprompt-caching--plain-english

Prompt Caching

TLDRPay once to read it, reuse it cheaply.

Watch a kitchen during the rush. The ticket lands and the cook does not hunt for an onion. It is already diced. Stock is simmering. Sauces sit in little containers. That prep has a name: mise en place.

Prompt caching is the model's mise en place.

Every turn, the model re-reads its entire context window from scratch. Your long system prompt. The docs you pasted. The project rules. The stack you picked in the builder. Hit send again and it reads all of it again, top to bottom, like the first time. That is slow — and if you are paying per token through an API, it is expensive. You are re-chopping the same onion on every message.

Caching preps the parts that do not change and holds them ready.

The stable prefix gets processed once and set aside. Next turn, instead of re-reading all of it, the model grabs the prep that is already done and only chews on what is new — your latest question, the fresh error paste, the one line you added.

You feel this in two ways:

  1. Replies come back faster. Less to re-read means less time staring at the thinking dots.

  2. It is cheaper. Reused prep costs a fraction of fresh text — often roughly a tenth of the price for the cached chunk, depending on the provider.

The catch: the prep does not sit out forever. Go idle long enough and the kitchen tosses it. Come back later and the onion gets chopped fresh again, at full price. A fast back-and-forth in one session keeps reusing the bowl.

The lesson if you are building or prompting:

Put the big, stable material at the top and leave it alone.

  • Long instructions, reference docs, repo context, rules — stack those first and do not edit them mid-chat.
  • The thing that changes — the actual question — goes at the bottom.

Why does order matter? The prep only holds while nothing above it moves. Change one word near the top and everything below has to be re-chopped, because the prefix is not the same prefix anymore. Keep the steady stuff steady and you keep the discount.

Most hosts do this quietly. Cursor, API providers, agent harnesses — you rarely flip a switch. Everything you leave unchanged is prep you do not pay to redo.

Related

  • Token
  • Context Window
  • System Prompt
  • Session
PrevToken

How AI Works

NextSession