r/nextjs • • Oct 24 '26

Next.js 16 cacheComponents & use cache vs. custom caching (Redis) with Payload CMS? How are you handling large sites in production?

Hey everyone,
I
I’m about to start a new project pairing Next.js with Payload CMS using its Local API (querying the database directly via Node on the server), and I’m weighing my options.
I’m curious how others are tackling this in production, especially for sites with a large number of pages:
The Native Approach: Are you diving into Next.js 16's cacheComponents with 'use cache' and cacheLife / cacheTag? If you are deploying outside of Vercel, how smooth is configuring cacheHandlers (plural) for a custom backend like Redis?

The Remote Directive: For multi-instance or serverless environments, are people actually using 'use cache: remote' in production, or do you find yourselves falling back to manual caching layers?

Bypassing Framework Caching: Do you completely disable Next's default caching behaviors for dynamic content and handle caching granularity yourself (e.g., wrapping Payload Local API calls explicitly with Redis/Memcached)?

Payload + Local API Specifics: Since Payload's Local API bypasses network overhead and talks straight to the database, wrapping those calls or components with 'use cache' seems powerful, but invalidation via revalidateTag needs to line up cleanly with Payload's hooks (e.g., afterChange). Has anyone hit weird edge cases with this combo at scale?

What has worked best for you when managing hundreds or thousands of pages where you need aggressive caching alongside instant editorial updates? Would love to hear what your current production setup looks like.

29 Upvotes

30 comments sorted by

View all comments

1

u/Chris_Lojniewski 24d ago

Whi's per-instance thing and u/AmanYadav_AY listing tags are the big two. The listing one bit us on a sanity + next site at Pagepro (my company, we don't run payload but invalidation works the same). Article pages revalidated on publish, the blog index didn't, and an editor noticed before we did 🙃

one that's not in the thread yet: nested dynamic routes. something like /products/[group]/[id] rendered fine on a direct load and white-screened on client-side nav from the parent. the client router used a parent-level cache entry so the child got the wrong key. since then we test every dynamic route both ways, direct URL and internal navigation. they go through different code paths and a test that only loads URLs directly won't catch it

on redis i'm with u/SameLink_io , single box until you've actually measured a problem. default cache + tags covers more than people expect

how many instances are you planning to run?

1

u/Emergency_Net85 24d ago

We're deploying to Kubernetes, which is precisely why I’m looking at Redis right off the bat. Since K8s is going to spin pods up/down, scale horizontally, and load-balance across multiple instances, sticking purely to local in memory cache is a nonstarter for us, we’d hit that exact 'per-instance' issue where Pod A revalidates on an editor update, but Pod B keeps serving stale content

2

u/Chris_Lojniewski 24d ago

Fair, k8s changes it. with pods scaling up and down redis from day one makes sense, you'd hit the per-instance thing in week one

u/pikafackjoo above is basically your setup (3 pods, invalidation landing on 1 of 3), worth reading their comment twice. a few things i'd add on top:

- next has two handler configs. cacheHandler (singular) covers ISR and the fetch/data cache, cacheHandlers (plural) is what 'use cache' and 'use cache: remote' go through. point both at redis or one layer quietly stays per pod

- tags need syncing too, not just entries. that's the refreshTags() bit Whi mentioned, otherwise pod B still thinks its tag is fresh

- rolling deploys: old and new pods share the same redis for a few minutes, so prefix keys with the build id like Aman said. a new pod reading an entry the old code wrote is a fun one to debug

- next/image optimizes and caches per pod as well, so either a shared loader (imgproxy like pikafackjoo) or put the CDN in front

- give staging its own redis db or at least its own key prefix. on one project we pointed staging at the same redis and it ate the rate limit faster than anyone expected 🙃

Are you planning redis just as next's cache, or also as a data cache around the local api calls?

1

u/Emergency_Net85 24d ago

I was actually planning to use Redis for both: next's cache (use cache + sync tags across pods) but also custom wrappers around the Payload Local API calls.. What do you recommend here?

Man. given all these edge cases and setup pain points, though... is it not simpler to just completely disable next cache :)

1

u/SameLink_io 21d ago edited 21d ago

I don't have a production instance count for that exact setup; I was describing the cache boundary rather than a deployment I'm sizing. For an HA app, I'd start with two replicas, verify shared cache and invalidation across both, then scale based on load tests. The exact count matters less than ensuring every rendering and data-cache layer shares state and receives the same invalidations.