Workers KV is Cloudflare's eventually consistent key-value store: writes land in a small number of central stores, and values are cached in the data centers that read them. EOXLABS uses KV for data read on almost every request and changed rarely, such as feature flags, routing tables, tenant configuration and published content, where a short propagation delay is acceptable.
How does Workers KV behave after a write?
Cloudflare's explanation of how KV works is the document every KV design should start from. A write goes to the central stores and is not pushed to every location. A read in a location that has the value cached (a hot read) returns at once; a cold read climbs through a regional tier and a central tier to the central stores. KV refreshes popular cached values in the background.
The consequences are specific:
- A change is usually visible at once in the location where it was made, but Cloudflare does not guarantee even that.
- In other locations a change can take 60 seconds or more to appear, as cached copies expire.
- Negative lookups are cached too. A key that was read before it existed can keep returning
nullfor the same delay after it is created. - Concurrent writes to one key overwrite each other, and the last write wins.
- A key accepts at most 1 write per second; faster writes fail with
429errors.
The cacheTtl read option trades freshness for latency. It defaults to 60 seconds and cannot be set below 30; a longer value means fewer cold reads and a longer window in which a changed key is served stale.
How does EOXLABS use Workers KV in practice?
Immutable versions behind a small pointer. A changed configuration is written under a new versioned key, and only then is a short pointer key updated to name it. Readers follow the pointer. A versioned key never changes after it is written, so it can carry a long cacheTtl safely; only the pointer uses the default. Readers in any location see either the old version or the new one, never a mix.
// Writer (one process only): the new version lands before the pointer moves.
await env.CONFIG.put(`tenant:${tenantId}:v43`, JSON.stringify(nextConfig));
await env.CONFIG.put(`tenant:${tenantId}:current`, "v43");
// Reader (every request): a short-lived pointer, then a long-lived immutable value.
const version = await env.CONFIG.get(`tenant:${tenantId}:current`);
const config = version
? await env.CONFIG.get(`tenant:${tenantId}:${version}`, { type: "json", cacheTtl: 86400 })
: null;
One writer per namespace. Cloudflare's write API reference notes that writing from a single process (Wrangler, the API or a Durable Object) avoids competing concurrent writes. EOXLABS routes every write for a namespace through one such path. KV itself documents the stronger variant: send all writes for a key through one Durable Object to get write-after-write consistency, while reads stay on KV.
Values in metadata for listings. list() returns up to 1,000 keys per call with a cursor, and each key can carry up to 1,024 bytes of metadata. Small values stored in metadata come back with the listing, which saves a get() per key.
Bulk reads. get() accepts an array of up to 100 keys, and Cloudflare's read API reference counts that bulk request as a single operation against the per-invocation limit.
Expiring keys for short-lived data. expiration and expirationTtl delete a key automatically; neither accepts a target less than 60 seconds away.
EOXSCRIPTUM, the EOXLABS edge-native headless CMS, runs on Workers, D1, R2 and KV. In content systems built on those primitives, the general pattern is that published content and settings are read from KV, while the editable source of truth lives in a store that supports queries.
Is Workers KV safe for sessions and credentials?
Cloudflare's storage options guide recommends KV for session data, API keys and configuration, because they are read at high rates, rarely modified and do not need immediate consistency. EOXLABS agrees for the read path and disagrees for revocation. A revoked session or key can stay valid in other locations for 60 seconds or more, and longer if it was read with a high cacheTtl. Where revocation must take effect at once, the authoritative state lives in a Durable Object or D1, and KV holds only data whose staleness is harmless.
KV encrypts every value at rest with AES-256 under keys Cloudflare manages. For OAuth tokens and similar secrets, EOXLABS adds application-level encryption on top, described in envelope encryption for OAuth tokens.
Where should configuration live: KV, D1 or a Durable Object?
| Workers KV | D1 | Durable Object | |
|---|---|---|---|
| Freshness after a write | 60 seconds or more in other locations | Sequentially consistent within a session; a bookmark shows a client its own writes | Strongly consistent |
| Write model | 1 write per second per key; last write wins | Single-threaded primary; batch() is a transaction | Single-threaded object; transactional storage |
| Reading it | Get by key, list by prefix | Any SQL query | SQL, but only from inside the object |
| Largest value | 25 MiB | 2 MB per row | 8 MB per row or key-value pair |
| Best fit | Flags, routing tables, published content | Configuration that is edited, versioned and queried | Settings that must change atomically with other state |
For multi-venue platforms in hospitality and membership, venue settings read on every request are a natural KV workload; the audit history of who changed them belongs in D1.
When not to use Workers KV
- Counters, rate limits and inventory. KV offers no atomic increment, and one key takes one write per second. A Durable Object owns that state.
- Revocation lists and permissions that must apply immediately. Propagation can take 60 seconds or more.
- Read-after-write across locations. A user who saves a setting and reloads through another data center may see the old value.
- Write-heavy keys. Cloudflare's own guidance is that a key updated tens or hundreds of times per second is a poor fit.
- Anything that needs a query. Beyond lookups by key and listings by prefix, use D1.
KV is the configuration layer of the EOXLABS stack and a routine part of edge architecture work.