Prompt caching works by storing and reusing the Key-Value (KV) cache entries generated by the LLM's attention layers for stable prompt prefixes, eliminating redundant computation of these expensive internal representations for repeated contexts, thus dramatically reducing inference costs.