#Example with caching and revalidation

1 messages · Page 1 of 1 (latest)

blissful laurel
#

Hello! I am looking for examples using caching and revalidation logic to some degree.
My Next.js app will likely be built without access to DB, so no build-time generation is possible.

I am not super familiar with modern Next.js, and less so with the combination of Payload and Next.js
What are the best practices with caching and revalidation?

lethal gobletBOT
blissful laurel
#

After some discussion with my good friend Claude, ISR with revalidatePath() / revalidateTag() seems to be the optimal solution. If anyone has experience with this in particular and have thoughts to share, please feel free

blissful laurel
#

Looking at specifically unstable_cache and revalidateTag()

But it's a bit tricky to know how much to revalidate if you change, let's say, a collection that's referenced in a global. Do you revalidate every tag associated with that global. Maybe good enough to revalidate everything

modern vigil
#

Hey, I've been using cache method described in this article lately and i'm pretty satisfied with it. I was fetching most of the data on the server inside the indivudal layout blocks components, so updating let's say team members collection would cause revalidating the team-members tag with this approach i didn't need to revalidate the individual pages. For the global i would just simply experiment whether updating only the global cache makes the other content change. https://blog.stackademic.com/how-to-speed-up-your-payload-cms-site-with-unstable-cache-7bbeb8d95a23

Medium

A practical guide to boosting performance in Next.js 15 by caching database queries with unstable_cache.