Newshot

Gemini Cut Next.js Daily Costs by 55%—What Did It Change?

AI summary

When Philipp Schmid's Next.js personal blog saw traffic rise 63%, its daily infrastructure cost instead fell from $0.36 to $0.16. Gemini 4 Neon did not switch servers; over 13 autonomous runs it rewrote how the blog delivers assets, converting accidentally dynamic routes to static generation, adding a cached Sharp AVIF/WebP and OG image pipeline, splitting CSS/JS by route, and adding Speculation Rules for prefetching.

Translation(model translation, not the source's own text)

Gemini Cut Next.js Daily Costs by 55%—What Did It Change?

Philipp Schmid used a single prompt to let Gemini 4 Neon autonomously optimize his personal Next.js blog. It converted misconfigured dynamic routes to static generation, cached and compressed images, scoped CSS and JavaScript per route, then verified the changes with desktop and mobile screenshots, ultimately reducing daily infrastructure cost from $0.36 to $0.16 while traffic increased 63%.

Cover image from Philipp Schmid (Google DeepMind Developer Experience) (direct link to official site)
Cover image from Philipp Schmid (Google DeepMind Developer Experience) (direct link to official site)
  • Converted all misconfigured dynamic routes to static generation or SSG
  • Used a Sharp pipeline to generate AVIF, WebP, and OG images
  • Scoped CSS and JavaScript loading per route
  • Used dual-platform screenshots and automatic rollback to ensure appearance stayed unchanged

Source is from the head of Developer Experience at Google DeepMind; the content is used to showcase the company's own model capabilities; production data comes from his personal blog and has not yet seen third-party retesting.

When you open the Vercel billing page, rising traffic usually means the server has to do more work too. Philipp Schmid's personal Next.js blog showed a different picture: after traffic increased 63%, daily infrastructure cost instead dropped from $0.36 to $0.16. The key is that Gemini 4 Neon did not change servers, but instead autonomously rewrote the blog's resource delivery approach 13 times in a row.

What moved first was not the server, but the routes

Gemini 4 Neon did not start by lowering the server unit price; it first looked at what rendering method the blog actually used. The routes that had accidentally been made dynamically rendered were the first thing that needed to change.

Dynamic rendering (generating pages on each request) means page content must be generated after the server receives a visit request. For blog pages whose content can be prepared in advance, this adds an unnecessary segment of runtime work. Gemini 4 Neon changed all these routes to static generation or SSG (generating static pages at build time), moving page generation timing from request time to build time.

After 13 autonomous runs, not a single misconfigured dynamic route remained; all were converted to static generation, with 100% coverage.

It did not stop after making the changes. It built a cached Sharp AVIF/WebP and OG image pipeline for images, split CSS/JS by route so that only the parts needed by the current page are loaded, and also added Speculation Rules to let the browser prefetch in advance. Each round of changes was committed to git by the system itself, with desktop and mobile screenshot comparisons run; 27 screenshots matched pixel by pixel, and any regression triggered automatic rollback.

Images are processed only once, then served from cache

Gemini 4 Neon connected image processing into a cached production line: images are processed only once, results go into cache, and subsequent requests reuse them directly.

Philipp Schmid explained this transformation clearly on X: the image processing pipeline is built with Sharp. Sharp is an image processing library in the Node.js ecosystem, responsible for processing original images into the image versions the site needs.

This pipeline outputs three types of images. AVIF and WebP are compressed formats for web display, while OG images are preview images used when a page is shared to social platforms (preview images shown during social sharing). Beyond these three outputs, the original text does not provide compression ratio, file size, cache hit rate, storage location, or invalidation policy.

What can be confirmed is only the reuse method: derived versions of the same image do not need to be handed to Sharp again on every request; after a new result is generated, it directly becomes cache content available to subsequent requests. The cost reduction on the image side comes from here—generate once, reuse repeatedly.

Each route gets only its own share

Gemini 4 Neon did not rebundle all front-end resources; instead, it made each route load only the CSS and JavaScript it needs.

As a result, the browser receives fewer resources. Client JS dropped from 237KB to 142KB, and CSS from 81KB to 37KB. Converted to percentages, the former decreased by 40% and the latter by 54%.

What was saved is send volume, not compression ratio. The key action is "scoping by route": each route has a corresponding CSS and JavaScript loading scope, and the page uses only its own part rather than sending resources for all pages to the user together.

Gemini 4 Neon also added Speculation Rules (speculation rules, allowing the browser to prepare in advance pages the user may visit). The browser predicts the route the user may open next based on user behavior and prepares the required resources in advance. The original text does not give the specific benefit this brought, so do not count it as a main contributor to cost reduction.

Appearance unchanged, verified pixel by pixel with 27 screenshots

Every autonomous run had to answer: are the desktop and mobile pages after the change exactly the same as before?

The optimization process Philipp Schmid published on X gave the answer: across 13 autonomous runs, screenshots were verified every time, on both desktop and mobile, 27 in total, all pixel-matched. Before-and-after page screenshots were placed together for pixel-by-pixel comparison, with no round skipped.

Pixel matching here (comparing each pixel position and color) means that if font size, spacing, or image position is off by one pixel, the comparison fails.

The prompt also required each run to commit a Git record. (Saving the history of every code change) In this way, each optimization leaves behind an inspectable and recoverable version node.

Once a run shows regression, the system automatically rolls back. Regression here means the optimization result did not pass verification or performed worse; automatic rollback withdraws the failed version to prevent unconfirmed changes from remaining on the page.

The bill went down, but the page got faster

In a production environment validation lasting 24 hours, traffic increased 63% compared with before optimization, page speed improved, and daily infrastructure cost dropped from $0.36 to $0.16.

MetricBefore optimizationAfter optimizationChange
Mobile LCP912ms380msSpeed is 2.4 times the original
Daily infrastructure cost$0.36$0.16Down 55%
Daily compute usage0.94 GB-h0.01 GB-hDown 99%
Traffic during the same periodIncreased 63%Not a tradeoff of lower traffic for low cost

For mobile LCP (time required for largest contentful paint), just look at the table.

Compute usage dropped the most sharply, but it is the computation executed when the server generates pages, measured in GB-h (compute hours), not network transfer traffic. A 99% drop in GB-h only shows that server-side computation decreased; it does not mean bandwidth usage or visit volume changed.

The cost basis should also be understood clearly: this bill is closer to actual spending, but it covers only the reported blog's daily infrastructure cost and does not include all development and operation expenses such as labor and model calls.

Can this autonomous optimization process still maintain the same proportional cost reduction when applied to production sites with more complex code and more varied pages?

Source: a production case published on X by Philipp Schmid (Google DeepMind Developer Experience); the basis is 24 consecutive hours of data from a personal Next.js blog, traffic increased 63% compared with before, transformation cost reduction was 55%, page verification covered 27 desktop and mobile screenshots, and there has been no third-party retesting yet.

Glossary · Plain-language notes appearing in this article

Full articles on deep dives, research interpretations, and tool tutorials, as well as all podcasts, are in the member area.

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by 听说了吗
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗