Skip to content
Docs
Core platformUpdated 2026-08-20

Cache and KV

Use Cloudflare KV for bounded cache and preview state without treating it as the source of durable truth.

What belongs in KV

The cache contract exposes get, set, and delete. Current uses include recent newsletter status and deterministic preview state.

KV is appropriate for:

  • recomputable values;
  • bounded status cache;
  • explicit development preview state;
  • data that tolerates eventual propagation.

What does not belong in KV

Do not place billing records, entitlements, user identity, file ownership, or webhook idempotency in KV. Those are durable D1 concerns.

Contract

Product code uses the cache module instead of addressing the CACHE binding directly. This keeps TTL, serialization, and key naming consistent.

Local development

The Cloudflare Vite and Wrangler environment provides a local KV implementation. E2E preparation clears isolated KV state before the suite.

Production guidance

  • Prefix keys by module and version.
  • Set an explicit TTL for caches.
  • Delete or bump the namespace when the serialized shape changes.
  • Expect eventual consistency across regions.
TanStarter SES documentationBuilt with TanStack Start and Content Collections.