Skip to main content

How I Made My Next.js + Payload Blog Static: Lighthouse 57 → 89, LCP 17.7 s → 3.7 s

A real Next.js 16 and Payload CMS performance case study: why pages never cached, a 7 MB image problem, static category pages and revalidation that works.

Amit Verma8 min read
How I Made My Next.js + Payload Blog Static: Lighthouse 57 → 89, LCP 17.7 s → 3.7 s

My blog index took 17.7 seconds to show its main content on mobile. Nothing was broken. No errors, no warnings, and every page looked fine on my laptop. This is how I found out why, and the five fixes that took it to 3.7 seconds, with every page now served from the CDN in about 30 ms.

This site runs on Next.js 16 (App Router) with Payload CMS 3, MongoDB and an Upstash Redis cache, deployed on Vercel. In November 2026 I ran a proper performance audit on it, and the results were humbling: the blog index scored 57 in Lighthouse on mobile, with its largest content appearing after 17.7 seconds. The homepage scored 73.

This post is the case study: the measurements, the wrong first guess, the real causes, and what I changed. Every number here comes from actual Lighthouse runs on the live site, simulated mobile, before and after.

The results first

  • Blog index (/posts): Lighthouse 57 → 87–89, largest contentful paint (LCP) 17.7 s → 3.7 s
  • Homepage: Lighthouse 73 → 86, LCP 6.3 s → 4.0 s
  • Server response: every page now served from Vercel's CDN in about 30 ms

Getting there took five changes. Two of them were one-line fixes, and none of them was the thing I suspected first.

Step zero: learn to see what Next.js is actually doing

Before fixing anything, you need two ways of seeing whether a page is static or rendered on every request.

The build output. next build prints a table of every route with a symbol:

1├ ○ /posts                    1h      1y
2├ ● /posts/category/nextjs    1h      1y
3├ ƒ /api/search

○ is static, ● is prerendered from generateStaticParams, and ƒ is dynamic: rendered on the server for every single visit. Any content page showing ƒ deserves an explanation.

The response headers. In production, check what Vercel's CDN says:

1curl -s -o /dev/null -D - https://www.example.com/posts | grep -iE "x-vercel-cache|cache-control"

x-vercel-cache: HIT, STALE or PRERENDER means the CDN served it. MISS on every request, with cache-control: private, no-cache, no-store, means every visitor waits for a full server render. That second one is what every page on my site returned.

Fix 1: the cache that silently made every page dynamic

Every page was being rendered on every visit, so the CDN never cached anything. My first theory was a noStore() call I'd left in the footer, which opts a route out of caching. It was a real problem, and I removed it. Nothing changed. Every page was still dynamic.

So instead of guessing again, I compared evidence: a production build showed which routes were ƒ, and they had exactly one thing in common. They all read from Redis.

The cause was a library default. The Upstash Redis client makes its requests with fetch(), and defaults them to cache: 'no-store'. In the Next.js App Router, a single no-store fetch anywhere in a route opts the whole route into dynamic rendering, with no warning. The fix was one option:

1import { Redis } from '@upstash/redis'
2
3export const redis = new Redis({
4  url: process.env.UPSTASH_REDIS_REST_URL,
5  token: process.env.UPSTASH_REDIS_REST_TOKEN,
6  // Upstash defaults to cache: 'no-store', which makes every route that
7  // touches Redis dynamic in Next.js. CMS hooks clear the keys on change.
8  cache: 'default',
9})

After this, the homepage and every blog post turned from ƒ to ○ and ● in the build output. This was the single biggest win of the whole audit, and it's worth checking in any Next.js app that uses a REST-based client: database SDKs, feature flags, analytics. If it uses fetch under the hood, its cache option decides whether your pages can be static.

Fix 2: seven megabytes of images on the blog index

The 17.7-second LCP on /posts wasn't a rendering problem at all. Lighthouse's largest-contentful-paint element was the featured post's cover image, and the page was downloading about 7 MB of images. Two things were wrong:

  • The featured card used a raw <img> pointing at the full-size upload, so a 2 MB original was downloaded to fill a card.
  • Every image used quality={100}. Setting it back to the default of 75 made a measured image go from about 400 KB to 118 KB, with no visible difference.

The fix was to send every card image through next/image with an honest sizes value, and to mark only the one LCP image as a priority:

1<Image
2  src={post.coverUrl}
3  alt={post.title}
4  fill
5  priority // only the featured card: it's the page's LCP element
6  sizes="(min-width: 768px) 50vw, 100vw"
7  className="object-cover"
8/>

The sizes attribute matters as much as the component. Without it, the browser assumes the image is as wide as the viewport and picks a much larger file than the card needs. I've written a whole guide on this in Next.js Image Optimization That Designers Trust.

Fix 3: a hero that waited for an animation

The homepage's LCP element was a paragraph of text in the hero, and it appeared after 6.3 seconds. The text itself arrived quickly. It just stayed invisible until a scroll-animation library finished loading and faded it in.

Scroll animations on content above the fold are an LCP trap: the browser has the content, but you've told it not to show it. I removed the animations from the hero and kept them only for sections further down the page. The rule I follow now: nothing in the first screen waits for JavaScript to become visible.

Fix 4: a query string that kept the blog index dynamic

Even after Fix 1, the blog index stayed dynamic. It filtered posts by category with a query string, /posts?category=nextjs, which meant the page read searchParams. In Next.js, reading searchParams opts a page into dynamic rendering, because its output depends on every request.

The fix was to give categories real routes instead:

1// app/(frontend)/posts/category/[category]/page.tsx
2export async function generateStaticParams() {
3  const categories = await getPostCategories()
4  return categories.map((c) => ({ category: c.slug }))
5}
6
7export default async function Page({ params }: { params: Promise<{ category: string }> }) {
8  const { category } = await params
9  // ...render the same listing component, filtered by this category
10}

Now /posts and every category page are prerendered. Real category URLs also turned out to be better for SEO: each category gets its own title, description and canonical URL, and appears in the sitemap.

Old links kept working through a permanent redirect that matches the query string, in next.config.js:

1{
2  source: '/posts',
3  has: [{ type: 'query', key: 'category', value: '(?<category>[a-z0-9-]+)' }],
4  destination: '/posts/category/:category',
5  permanent: true,
6}

Fix 5: keeping static pages fresh when content changes

Static pages are only useful if they update when an editor publishes. Payload's afterChange hooks are the natural place for that. When a post is published, the hook tells Next.js which pages are now stale:

1import { revalidatePath, revalidateTag } from 'next/cache'
2
3function revalidateListings() {
4  revalidatePath('/')
5  revalidatePath('/posts')
6  // Patterns must include the route group, or they silently match nothing.
7  revalidatePath('/(frontend)/posts/page/[pageNumber]', 'page')
8  revalidatePath('/(frontend)/posts/category/[category]', 'page')
9  revalidateTag('pages-sitemap', 'max')
10}

Two details here cost me time:

  • Route groups belong in dynamic patterns. My pages live inside an app/(frontend) route group. revalidatePath('/posts') works without it, because it's a literal path. But a dynamic pattern like /posts/category/[category] has to include the group, /(frontend)/posts/category/[category], or it matches nothing. There's no error. The category pages simply stayed stale.
  • revalidateTag takes two arguments in Next.js 16. The single-argument form is deprecated, and 'max' is the recommended profile: visitors get the cached page instantly while the fresh one is built in the background.

I only found the route-group bug because I tested the real behaviour: publish a post on a production build, load the category page, and check whether the new post appears. A unit test of the hook would have passed. The type-checker was happy. Only the end-to-end check could fail.

How I verified each fix

Every change went through the same three checks:

  1. Build output: does the route show ○ or ● instead of ƒ?
  2. Production headers: does a second request return x-vercel-cache: HIT?
  3. Lighthouse on the live site, run twice per page, because a single run can be noisy. One cold homepage run scored 64; the next scored 86. Never trust a single number.

What's still left

The scores aren't 100, and I'd rather be honest about why. On simulated mobile, LCP is still around 4 seconds. The homepage ships JavaScript that isn't needed for the first screen, and on the blog pages the main image still starts loading later than it should. Those are the next targets. The difference is that they're now ordinary optimisation work, not architecture problems hiding behind a cache that never worked.

Checklist for your own Next.js + CMS site

  1. Read your build output. Every ƒ on a content page needs a reason.
  2. Check x-vercel-cache in production, not just locally.
  3. Audit libraries that use fetch under the hood for cache: 'no-store' defaults.
  4. Never read searchParams on pages that should be static. Use real routes instead.
  5. Send every image through next/image with honest sizes, default quality, and priority only on the LCP image.
  6. Keep the first screen free of JavaScript-dependent visibility, like fade-in animations.
  7. Revalidate from CMS hooks, including route groups in dynamic patterns.
  8. Verify with an end-to-end test: publish content, then load the page.

FAQ

Why is my Next.js page dynamic when I didn't opt into it?

Something in the route reads request data or opts out of caching: cookies(), headers(), searchParams, noStore(), or a fetch with cache: 'no-store', including fetches made inside third-party libraries. Check the build output to see which routes are dynamic, then look for what they have in common.

Does revalidatePath work with route groups?

For literal paths like /posts, you can leave the group out. For dynamic patterns like /posts/[slug] with the type argument, include the route group as it appears in your app folder, for example /(frontend)/posts/[slug]. Otherwise the call matches nothing, without an error.

Is Lighthouse on simulated mobile realistic?

It's deliberately pessimistic: a mid-range phone on a slow connection. That's useful, because it exaggerates problems that real users on average devices still feel. Compare runs against each other, run each page at least twice, and check real-user data in Search Console's Core Web Vitals report once you have traffic.

Should a Next.js blog use Redis at all?

For mostly static content, the CDN cache usually makes a separate Redis layer unnecessary. I still use Redis for individual post data, but the blog listings no longer need it now that they're static pages. If you do use Redis, make sure its client doesn't make your pages dynamic.

Share this article

Found it helpful? Share it with your network.

Keep reading