Next.js ISR on OpenNext + Workers KV: why the cache never expires and how to cap it
Meathill traces a KV storage overage on his own site to OpenNext's KV incremental cache writing keys without a TTL and keeping every deploy's build-prefixed snapshot, then shows how he rebuilt the cache lifecycle.
- Products
- WorkersKV
- Source
- Author experienceMeathill’s blog (meathill.com)
- Author
- Meathill (@meathill1)
Key points
- The author found that OpenNext's KV incremental cache calls kv.put() without an expirationTtl (the source still carries a TODO about KV TTL), so a page's revalidate value does not make the KV entry expire.
- Each opennextjs-cloudflare deploy runs populateCache, which bulk-puts every prerendered page's HTML and RSC payload under the new Build ID prefix. Old prefixes are never read again but stay stored; after dozens of deploys his namespace reached 24 GB, and the billing period showed 3.59 GB-month of storage.
- His fix: move to a new namespace and delete the old one, wrap the cache so every put carries expirationTtl = min(7 days, max(60 s, 2 × revalidate)), and patch the bulk-put step to add expiration_ttl 604800.
- Official KV docs (rechecked 2026-10-14): Workers Paid includes 1 GB stored, then $0.50 per GB-month; each key in a REST bulk write counts as one write; expirationTtl must be at least 60 seconds, and expired keys stop counting toward storage.
Original sources
Published
Next.js ISR on OpenNext + Workers KV: why the cache never expires and how to cap it
Open original sourceMeathill traces a KV storage overage on his own site to OpenNext's KV incremental cache writing keys without a TTL and keeping every deploy's build-prefixed snapshot, then shows how he rebuilt the cache lifecycle.
The author shares the article on 𝕏 and lists his 2026 bill surprises by month: image transformations (July), containers (August), self-inflicted prefetch traffic (September) and the KV cache (October).
Read on 𝕏Meathill
@meathill1 · Original 𝕏 post
作为Cloudflare资深用户,我的独立开发生涯不断被账单背刺: - 七月:图片转换被坑 - 八月:容器使用被坑 - 九月:prefetch DDOS 自己 - 十月:KV 缓存爆炸 这次分享的,就是我本以为开源框架应该已经做好了,但实际上 // TODO 多年的一个缓存陷阱: https://t.co/NjRzSo510W
More to read
Cloudflare costs $5 a month, but the bill is not capped
不追高 (@Ariella1213) writes an X article explaining that Workers Paid’s $5 is a minimum, that per-product limits and budget alerts do not cap the account bill, and how denial-of-wallet requests, write amplification, delayed stops and background retries add cost.
Jiuhong: a vibe-coded Durable Objects bug, a $600+ overnight bill and a reported 80% account credit.
Replying on X in the shmily7 thread, Jiuhong (@indiehacker9527) says a bug from vibe coding in Durable Objects produced a bill of more than $600 overnight a few months earlier. After several rounds of negotiation stressing system defects, he says 80% was returned as account credit for future charges rather than to his card, that Cloudflare promised product improvements, and that he also received a startup credit package.
Cloudflare billing pitfalls thread
The author organizes Cloudflare billing risks by product and shares experience with budget alert emails.