OpenNext on Cloudflare: 7.87M R2 reads from cache hits and 10M Worker requests from a prefetch loop
Meathill debugs two back-to-back cost spikes on a Next.js 16 site on Workers: background R2 reads on every RegionalCache hit, then an infinite _rsc prefetch loop from OpenNext cache interception, with the config changes that stopped each.
- Products
- WorkersR2
- Source
- Author experienceMeathill’s blog (meathill.com)
- Author
- Meathill (@meathill1)
Key points
- With about 2,300 daily visitors, R2 showed 19,000 Class A and 7.87 million Class B operations. The author reads a ratio above 400:1 as reads on cache hits rather than misses, and found Class B closely tracking zone requests.
- Cause: under Next.js 16, OpenNext's withRegionalCache defaults shouldLazilyUpdateOnCacheHit to true, so each hit triggers a background R2 read via waitUntil. Short s-maxage (600 s home, 1,800 s inner pages) and hundreds of independent PoPs amplified it.
- R2 fixes: set shouldLazilyUpdateOnCacheHit to false, move the incremental cache to its own bucket with a lifecycle rule expiring incremental-cache/ after 7 days, cut image sizes to five, and raise s-maxage and revalidate to 86,400 s.
- Two days later Worker requests passed 10 million and observability usage spiked. He traced the endless _rsc prefetches to enableCacheInterception: true (opennextjs-cloudflare issue 1348), turned it off, and added prefetch={false} to low-intent links in 35 components, cutting first-screen prefetches by over 70%.
- Official docs (rechecked 2026-10-14): GetObject and HeadObject are R2 Class B operations; lifecycle rules usually delete expired objects within 24 hours and deleted objects stop billing; Workers Paid includes 10 million requests a month, then $0.30 per million.
Original sources
Published
乐极生悲的 Next.js+OpenNext 生产踩坑排错实录:被10+M R2读操作和10M+ Worker 请求轮番肘击的一天
Open original sourceMeathill debugs two back-to-back cost spikes on a Next.js 16 site on Workers: background R2 reads on every RegionalCache hit, then an infinite _rsc prefetch loop from OpenNext cache interception, with the config changes that stopped each.
Read originalArchived
This archive does not contain the complete text.
乐极生悲的 Next.js+OpenNext 生产踩坑排错实录:被10+M R2读操作和10M+ Worker 请求轮番肘击的一天
随便用,我跟你讲,随便用!
Live post while debugging: R2 Class B reads had exploded and the author was tracking down the cause.
Read on 𝕏Meathill
@meathill1 · Original 𝕏 post
艹,next.js 真的有 bug,16.3.x 之后,会死循环 prefetch,昨天的流量直接就把我的 Worker 额度全线打爆了…… https://t.co/NS8PjNxk9T
The author shares the write-up of the R2 read and Worker request incidents on 𝕏.
Read on 𝕏Meathill
@meathill1 · Original 𝕏 post
https://t.co/jDUdD5pUz6 好久没写博客,最近踩一大坑,写出来给大家当前车之鉴。前几天关于AMD免费AI API的文章侥幸成为爆款,把https://t.co/CZZ6zVzqV0网站不够扎实的基础暴露的一塌糊涂。因为缓存设置不当加上中招next.js无限循环prefetch的bug,所有Worker额度均被打爆。希望对大家有帮助。
Follow-up: once the free Class A quota was used up, the ISR cache on R2 cost him more than the Worker itself.
Read on 𝕏Meathill
@meathill1 · Original 𝕏 post
完蛋,上次的 bug 把这个月的 A 类操作额度也用完了,结果现在 ISR 页面缓存的价格反而比 worker 更贵……今天只好停掉 ISR 试试看,如果明天成本能降下来,以后低访问量的网页就不走 ISR 缓存了。
More to read
sean1093/purse-strings: in-process LLM spend budgets, with optional Durable Objects or KV stores
The MIT-licensed TypeScript library purse-strings (sean1093/purse-strings) is described as a denial-of-wallet guard for apps that call LLM APIs: per-user, per-session and global token, cost and request budgets, plus step, tool-call and time limits for agent loops. It has zero runtime dependencies and can keep counters in memory, Firestore, or Cloudflare Durable Objects or Workers KV. The README warns that with multiple process replicas, each replica enforces the limit, so the effective limit is N times the configured value unless a shared store is used, and that a Durable Objects or KV store is what a hard limit needs. Reviewed from the public README on 2026-11-19. Example figures in the docs include a user-daily cap of costUsd: 1 and a fleet-daily cap of costUsd: 200.
Kun Save Point (@Savepoint_kk): a D1 bug rewrote unchanged data into a $2,739.12 bill; $2,141 goodwill credit granted.
Kun Save Point (@Savepoint_kk), an indie developer who says he recently lost his job, says a bug repeatedly rewrote unchanged data while inefficient queries amplified reads, producing a $2,739.12 Cloudflare bill already paid via PayPal (D1 rows written $2,641.00, rows read $64.06, other services $34.06); he says his bills were usually under $10 a month. Cloudflare granted a $2,141 goodwill account credit under case #02391058. He asks for it to be converted into a refund to the original PayPal payment, or at least for relief on the $2,641 write charges, and later writes that the initial request was declined and has been reopened for additional review. On October 25 he adds that he missed the only alert email Cloudflare sent, whose amount was not particularly high, and received no further warning before the large card charge; on October 26 he writes that the refund request to the original payment method is still under further review. On November 10 he posts a timeline saying that after following up on November 10–11, support again stated the $2,141 could only remain as account credit and the remaining $598.12 was still undecided while the ticket was being closed. On 26 November 2026 the author posted another public thread asking what a "final decision" means. He says that in the first case an agent called a refund impossible as a "final decision," then submitted it for further review; that after several business days he was told the account credits could not be refunded while the remaining amount was still under review; and that the first case was later closed without a clear resolution of that remaining amount. He opened a second case; an agent said the remaining amount had been definitively rejected, another "final decision." After the author posted on X, a senior billing specialist (Agent D) confirmed that the previously rejected amount had actually been refunded. The author asked whether the larger $2,141 account credit could be converted into a cash refund; after being told it was under review, an agent from the first case declared another "final decision": no refund. The author asks who reviews these requests and why a supposedly final rejection was later followed by an actual refund, and says D1 on Workers Paid still lacks a configurable hard spending cap. The posts cite cases #02391058 and #02447083. There is no staff reply on that public thread.
Cloudflare Cost Hub: free-tier vs paid allowances, cost drivers and month-end forecasts
An MIT-licensed dashboard that signs in with Cloudflare OAuth, reads account analytics across products, colour-codes usage as free, within paid allowance or billable, ranks per-instance cost drivers, forecasts month-end cost and emails threshold and budget alerts.