When developing and testing LLM applications, you often make the same requests repeatedly during debugging and iteration. Helicone caching stores complete responses on Cloudflare's edge network, eliminating redundant API calls and reducing both latency and costs.
Looking for provider-level caching? Learn about Prompt Caching to cache prompts directly on provider servers (OpenAI, Anthropic, etc.) for reduced token costs.
Why Helicone Caching#
Avoid repeated charges for identical requests while testing and debugging
Serve cached responses immediately instead of waiting for LLM providers
Protect against rate limits and maintain performance during high usage
How It Works#
Helicone's caching system stores LLM responses on Cloudflare's edge network, providing globally distributed, low-latency access to cached data.
Cache Key Generation#
Helicone generates unique cache keys by hashing:
- Cache seed - Optional namespace identifier (if specified)
- Request URL - The full endpoint URL
- Request body - Complete request payload including all parameters
- Relevant headers - Authorization and cache-specific headers
- Bucket index - For multi-response caching
Any change in these components creates a new cache entry:
Cache Storage#
- Responses are stored in Cloudflare Workers KV (key-value store)
- Distributed across 300+ global edge locations
- Automatic replication and failover
- No impact on your infrastructure
Quick Start#
Enable caching
Add the Helicone-Cache-Enabled header to your requests:
Make your request
Execute your LLM request - the first call will be cached:
Verify caching works
Make the same request again - it should return instantly from cache:
Configuration#
Enable or disable caching for the request.
Example: "true" to enable caching
Set cache duration using standard HTTP cache control directives.
Default: "max-age=604800" (7 days)
Example: "max-age=3600" for 1 hour cache
Number of different responses to store for the same request. Useful for non-deterministic prompts.
Default: "1" (single response cached)
Example: "3" to cache up to 3 different responses
Create separate cache namespaces for different users or contexts.
Example: "user-123" to maintain user-specific cache
Comma-separated JSON keys to exclude from cache key generation.
Example: "request_id,timestamp" to ignore these fields when generating cache keys
All header values must be strings. For example, "Helicone-Cache-Bucket-Max-Size": "10".
Examples#
Use both provider caching and Helicone caching together by ignoring provider-specific cache keys:
Learn more about provider caching here.
This approach:
- Uses OpenAI's prompt caching for faster processing of repeated context
- Uses Helicone's caching for instant responses to identical requests
- Ignores
prompt_cache_keyso Helicone cache works across different OpenAI cache entries - Maximizes cost savings by combining both caching strategies
Avoid repeated charges while debugging and iterating on prompts:
Cache responses separately for different users or contexts:

Understanding Caching#
Cache Response Headers#
Check cache status by examining response headers:
Cache Duration#
Set how long responses stay cached using the Cache-Control header:
Common durations:
- 1 hour:
max-age=3600 - 1 day:
max-age=86400 - 7 days:
max-age=604800(default) - 30 days:
max-age=2592000
max-age=31536000)Cache Buckets#
Control how many different responses are stored for the same request:
With bucket size 3, the same request can return one of 3 different cached responses randomly:
Behavior by bucket size:
- Size 1 (default): Same request always returns same cached response (deterministic)
- Size > 1: Same request can return different cached responses (useful for creative prompts)
- Response chosen randomly from bucket
Cache Seeds#
Create separate cache namespaces using seeds:
Different seeds maintain separate cache states:
Ignore Keys#
Exclude specific JSON fields from cache key generation:
When these fields are ignored, requests with different values for these fields will still hit the same cache entry:
Common use cases:
- Ignore tracking IDs that don't affect the response
- Exclude timestamps for time-independent queries
- Remove session or user metadata when caching shared content
- Ignore
prompt_cache_keywhen using provider caching alongside Helicone caching
Cache Limitations#
- Maximum duration: 365 days
- Maximum bucket size: 20 (enterprise plans support more)
- Cache key sensitivity: Any parameter change creates new cache entry
- Storage location: Cached in Cloudflare Workers KV (edge-distributed), not your infrastructure
Related Features#
Cache prompts on provider servers for reduced token costs and faster processing
Add metadata to cached requests for better filtering and analysis
Control request frequency and combine with caching for cost optimization
Track cache hit rates and savings per user or application
