Next.js Discord

Discord Forum

ISR on Next 15.1.0

Answered
Cuvier’s Dwarf Caiman posted this in #help-forum
Open in Discord
Avatar
Cuvier’s Dwarf CaimanOP
Hi, i can't use ISR with this fetch response. I want to cache the response for 6 hours and then cache the new response for 6 hours and so on. I add revalidate = 15 just for test and it doesn't work
Image
Answered by B33fb0n3
Not really. You can make it fully static and revalidate it on demand. Then set up a route handler, that revalidates your route and this route handler will be called for example via a cron task. Somehow there need to be a request
View full answer

8 Replies

Avatar
Cuvier’s Dwarf CaimanOP
Also when running npm run build I get this
Image
Avatar
if you want to use generateStaticParams then you need to provide an array at the end:
return [
  {
    benefit: "..."
  }
]

You then want to revalidate it every 6 hours. 6 hours in seconds are 21600. So add the following to your page.tsx:
export const revalidate = 21600 // invalidate every 6 hours
Avatar
Cuvier’s Dwarf CaimanOP
What I was doing was not necessary, right? I don't have dynamic paths. The only thing I want to do is fetch every 6 hours, so just adding export const revalidate = 21600; is enough, right?
Image
Avatar
fetch every 6 hours
when there is a request to the website exactly each 6 hours, then yes, that will happen
Avatar
Cuvier’s Dwarf CaimanOP
Ok, thanks! Is it possible to set the revalidate time to a specific time? For example: 00hs && 06am && 12pm && 06pm?

If the request was at 00:30, it doesn't matter, next revalidate time is still 06am.
Avatar
Not really. You can make it fully static and revalidate it on demand. Then set up a route handler, that revalidates your route and this route handler will be called for example via a cron task. Somehow there need to be a request
Answer
Avatar
Cuvier’s Dwarf CaimanOP
Oh, ok. Thak you!
Avatar
happy to help