billflare.

Why Next.js images got expensive on Cloudflare: route them through /cdn-cgi/image and cache them

Meathill explains why the default /_next/image endpoint on OpenNext was uncacheable and rerun on every request, and replaces it with a custom loader to Cloudflare Image Transformations plus a long Cache Rule.

Products
WorkersImages
Source
Author experienceMeathill’s blog (meathill.com)
Author
Meathill (@meathill1)

Key points

  • The author found /_next/image responses carried no Cache-Control, cf-cache-status, ETag or Last-Modified, so browsers and the CDN kept re-requesting and every image hit the Worker. Overriding it with Cache Rules did not take effect.
  • Fix from the OpenNext docs: an image-loader.ts custom loader that emits /cdn-cgi/image/<options>/<src>, set as loader: "custom" in next.config. Responses then show unique_transformations_billing: true and respect Cache Rules.
  • He then adds a Cache Rule forcing one-year edge and browser TTL on the image path, notes that LRU eviction can still drop cold images from edge caches, and suggests Cache Reserve if no re-transformation can be tolerated.
  • Official docs (rechecked 2026-10-14): Images bills unique transformations once per calendar month; Free includes 5,000 and then returns error 9422 for new ones without charging; Paid includes 5,000, then $0.50 per 1,000. Cache Reserve needs a paid plan and bills storage plus Class A/B operations.

Original sources

  1. Published

    Next.js 图片怎么这么贵?!——Cloudflare 原生 Image Resizing 避坑与最佳实践

    Open original source

    Meathill explains why the default /_next/image endpoint on OpenNext was uncacheable and rerun on every request, and replaces it with a custom loader to Cloudflare Image Transformations plus a long Cache Rule.

    Read originalArchived

    This archive does not contain the complete text.

    Next.js 图片怎么这么贵?!——Cloudflare 原生 Image Resizing 避坑与最佳实践

    这项功能依赖部署平台,Vercel,Cloudflare 都支持。
  2. The author shares the image-cost article on 𝕏.

    Read on 𝕏

    Meathill

    @meathill1 · Original 𝕏 post

    Next.js <Image> 很好用,但在 Cloudflare Worker + OpenNext,默认图片优化可能悄悄变成“钱包黑洞”。 我帮朋友排查了一次每月近 $100 的账单,最后发现问题藏在 HTTP Header 里。 这篇文章记录了完整排查过程,以及如何用 Cloudflare 原生 Image Resizing + custom loader + 缓存规则,把成本优化下来,把性能提升上去。 https://t.co/3ULkkPFYl0
Official docsWorkers +3

Activate Workers Paid, R2, and Zero Trust subscriptions from the Cloudflare CLI or MCP

On 2026-11-25 Cloudflare announced that accounts can activate subscriptions, including Workers Paid, R2, and Zero Trust, from the Cloudflare CLI (cf) or Cloudflare MCP servers, without switching to the dashboard. The changelog says this requires cf 1.0.0-rc.5 or later, a fresh cf auth login so the session receives updated OAuth scopes, a verified email address, and an existing billing profile with a payment method on file. MCP clients that support elicitation show the plan price and ask permission before activating; clients that do not are directed to the dashboard.

Durable Objects

igorrizzom: a forgotten Durable Object alarm billed US$ 2,038; Support refunded US$ 1,533.29, leaving US$ 505.

X user @igorrizzom (Igor Rizzo), who also posted on Cloudflare Community as igorarm (urnaaovivo.com), says a personal, non-commercial prototype that collected public election data in Brazil was left running after the October 25 runoff. A Durable Object kept rescheduling itself via alarm every ~5 seconds and writing to SQLite, and the invoice reached US$ 2,038, almost all from DO rows written, with about 10k pageviews. The author says budget alerts were set up but went to an old inbox that was never checked, and that alerts do not stop usage. Spend limits for Workers and Durable Objects were only announced on November 13, after almost all of the usage; the author then set a US$ 1 spend limit, turned the collector off, and removed Cron Triggers. The author says Support refunded US$ 1,533.29 as a one-time courtesy. The remaining US$ 505, which the author later described as US$ 500 of usage plus the US$ 5 Workers Paid fee, was closed as final; the author asked for a supervisor review in case #02442826 (follow-up to #02435308) and also asked @SidChatterjee whether any goodwill path remained for pre-launch cases. There is no Cloudflare staff reply on the public X thread or the Community thread. Public Support actions are reported by the author.

Author experienceD1 +1

风易: On the free tier, do not wait synchronously for bookkeeping and log writes; return first, then persist to the database in the background with waitUntil

On 2026-11-16, X user @Michael_liyang (风易) wrote: on the free tier, do not wait synchronously for bookkeeping and log writes; return the response first, and throw write operations to the background. A synchronous write to D1 both slows the response and burns CPU time. The approach is: the response contains only the business result; bookkeeping goes through waitUntil to persist in the background; on failure, enter the queue for a catch-up write. The chain is request → call upstream → return the result first → write the books in the background → catch-up write on failure.