Next.js Discord

Discord Forum

Static pages / page build cache in an interval

Unanswered
Paul. posted this in #help-forum
Open in Discord
Hi there, I have a page which I would like to revalidate every 5 minutes. But during those 5 minutes (or whatever time I set) I want there to be a static build cache. (The content of the page won't change during that time)

I already setup a revalidate API route which gets called every five minutes. But the page still needs to compile whenever I make a first request after the page was revalidated.

Am I doing something wrong, or is this intended behaviour?

If so - how can I go about impementing the thing I would like?

10 Replies

Because this seems like it's what I'm looking for;

https://nextjs.org/docs/app/building-your-application/deploying#caching-and-isr

generate static pages

But I can't find how to implement this in the docs
bump :\
@Paul. Yes
Cuvier’s Dwarf Caiman
Then I believe you can just use https://nextjs.org/docs/app/api-reference/functions/unstable_cache with the revalidation option set to five minutes
@Cuvier’s Dwarf Caiman You can look here for more details about caching https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating
But that won't cache the page right? Like this will only cache my queries, which dont really need caching.

I just want the page result to load super fast from cache/disk. Because building thr page has quite a lot of rendering time.
Generating a huge table with lots of computations. (I also need to do a lot of API calls to populate thr data. So I rather not do that every time the page is loaded. Even tho I cache the API calls
Cuvier’s Dwarf Caiman
unstable_cache allows you to cache those computations