Skip to Content
Self-hostingvLLMPrefix caching

vLLM prefix caching

vllm enable-prefix-caching reuses KV cache blocks when requests share an identical prompt prefix — vLLM’s version of provider prompt caching.

Hub: vLLM.

Enable

vllm serve meta-llama/Llama-3.1-8B-Instruct \ --host 0.0.0.0 --port 8000 \ --max-model-len 8192 \ --enable-prefix-caching

Requirements

RequirementWhy
Stable prefix firstSystem + tools before dynamic user content
Same modelPrefix cache tied to weights
Fixed RAG system blockHigh hits on repeated templates

vs semantic caching

LayerMatchesSaves
vLLM prefix cacheIdentical prefix bytesKV recompute
Semantic cachingSimilar meaningFull inference skip

Troubleshooting

Hits stay zero — client reshuffles system prompt each turn; stabilize rules/MCP schemas like OpenRouter caching.

Check Prometheus metrics and TTFT on turn 2+ in agent loops.

Last updated on