For SQL databases and structured queries, see the data operation.
Configuration
KV (Key-Value Store)
Global key-value cache with eventual consistency. Perfect for configuration, sessions, and caching.GET Operation
PUT Operation
expirationTtl(number) - Seconds until expirationexpiration(number) - Unix timestamp for expirationmetadata(object) - Custom metadata (max 1KB)
DELETE Operation
LIST Operation
prefix(string) - Filter keys by prefixlimit(number) - Max results (default: 1000, max: 1000)cursor(string) - Pagination cursor
R2 (Object Storage)
S3-compatible object storage for files, images, backups, and large data.GET Object
PUT Object
httpMetadata(object) - Standard HTTP metadatacustomMetadata(object) - Custom key-value metadata (max 2KB)
DELETE Object
LIST Objects
prefix(string) - Filter by prefixlimit(number) - Max results (default: 1000)delimiter(string) - Directory delimitercursor(string) - Pagination cursorinclude(string[]) - Include metadata:['httpMetadata', 'customMetadata']
HEAD Object (Metadata Only)
Cache API
Edge cache for ultra-fast data access across Cloudflare’s global network.GET Operation
PUT Operation
ttl(number) - Seconds until expirationcacheControl(string) - Custom Cache-Control header
DELETE Operation
Choosing Between Storage Types
When to Use storage vs data
Use storage when you need:- ✅ Simple key-value lookups
- ✅ Object/file storage
- ✅ Temporary caching
- ✅ Global edge caching
- ❌ SQL queries
- ❌ Relational data
- ❌ Transactions
- ❌ Complex queries with JOINs
Examples
Session Management with KV and Cookies
Combine KV storage with the cookies operation for complete session management:File Upload to R2
API Response Caching
Bindings Setup
Configure storage bindings inwrangler.toml:
Performance Tips
KV Best Practices
- Keep values under 25MB (max limit)
- Use expiration to auto-cleanup
- Leverage eventual consistency model
- Cache frequently accessed keys
R2 Best Practices
- Use multipart upload for files >100MB
- Set appropriate content types
- Use prefixes for organization
- Leverage custom metadata for search
Cache Best Practices
- Set reasonable TTLs
- Invalidate on writes
- Use cache keys carefully
- Monitor cache hit rates

