Skip to main content
Access Cloudflare storage primitives for simple data persistence.
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

Output:

PUT Operation

Options:
  • expirationTtl (number) - Seconds until expiration
  • expiration (number) - Unix timestamp for expiration
  • metadata (object) - Custom metadata (max 1KB)

DELETE Operation

LIST Operation

Options:
  • prefix (string) - Filter keys by prefix
  • limit (number) - Max results (default: 1000, max: 1000)
  • cursor (string) - Pagination cursor
Output:

R2 (Object Storage)

S3-compatible object storage for files, images, backups, and large data.

GET Object

Output:

PUT Object

Options:
  • httpMetadata (object) - Standard HTTP metadata
  • customMetadata (object) - Custom key-value metadata (max 2KB)

DELETE Object

LIST Objects

Options:
  • prefix (string) - Filter by prefix
  • limit (number) - Max results (default: 1000)
  • delimiter (string) - Directory delimiter
  • cursor (string) - Pagination cursor
  • include (string[]) - Include metadata: ['httpMetadata', 'customMetadata']
Output:

HEAD Object (Metadata Only)

Returns object metadata without downloading the body.

Cache API

Edge cache for ultra-fast data access across Cloudflare’s global network.

GET Operation

PUT Operation

Options:
  • ttl (number) - Seconds until expiration
  • cacheControl (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
Use data when you need:
  • ❌ SQL queries
  • ❌ Relational data
  • ❌ Transactions
  • ❌ Complex queries with JOINs
See data operation for database queries.

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 in wrangler.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

Storage Limits

  • data - SQL queries and database operations
  • http - HTTP requests
  • queue - Message queues