samodra

2 min read

Moving my lessons site from Vercel to Cloudflare Pages

My lessons site almost got paused by Vercel, and it doesn’t get that many visitors.

The warning came as an email. My ISR Reads had reached 75% of the 1 million limit on the free plan. If usage hit 100%, the site would be paused. It is not a paid site either, so upgrading the Vercel plan was not a real fix.

A Vercel email titled “Your site is growing!” saying the free team has used 75% of the included free tier usage for Fast Origin Transfer (10 GB), and that projects will be paused automatically if the free usage is exceeded

The email in the screenshot is a similar notice, for Fast Origin Transfer (10 GB) on the same free team. The same warning applies: go past the free usage and the projects are paused automatically, or upgrade to Pro.

Where the reads came from

I audited the site again. The sidebar holds hundreds of links to lesson pages, and Next.js automatically prefetches the pages whose links are visible on screen. So a single visitor opening the site can trigger a dozen or more page reads within seconds.

The site has about 1,140 lesson pages. In the infographic below, that works out to one visit turning into 10+ page reads within seconds, and 75% of the ISR Reads limit gone.

Why static was the better fit

Looking at what the site actually contains, almost everything is static, and the lessons rarely change. Rendering them through SSR and ISR on every request was more machinery than the content needed.

So I moved it to Cloudflare Pages:

  • The lessons become fully static. I exported them as a static site on Pages, so every lesson is a plain file served from the CDN.
  • The part that needs a server is small. Learning progress and reviews are the only things that need a backend, so I migrated those to a small Hono API on Cloudflare Workers.

Both pieces fit in Cloudflare’s free plan.

Before and after comparison. Before: Vercel Hobby, one Next.js app with SSR, ISR and API routes, about 1,140 lesson pages, ISR Reads at 75% of the 1M limit. After: Cloudflare Free, a static export on Pages plus a small Hono API on Workers. The static export shrank from 11,596 to 5,926 files and from 3,177 MiB to 304 MiB

Trimming the export

I also trimmed the static export. It went from 11,596 files to 5,926, and from 3,177 MiB to 304 MiB.

What I gave up

The downside is deployment. For now I deploy manually from my laptop, and it is not automatic the way it was on Vercel.

I’m also curious whether anyone else has hit a plan limit because of prefetch. If it has happened to you, I’d like to hear how you handled it.