ISR on Next 15.1.0
Answered
Cuvier’s Dwarf Caiman posted this in #help-forum
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
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
8 Replies
Cuvier’s Dwarf CaimanOP
Also when running npm run build I get this
if you want to use
You then want to revalidate it every 6 hours. 6 hours in seconds are 21600. So add the following to your page.tsx:
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
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?fetch every 6 hourswhen there is a request to the website exactly each 6 hours, then yes, that will happen
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.
If the request was at 00:30, it doesn't matter, next revalidate time is still 06am.
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
Cuvier’s Dwarf CaimanOP
Oh, ok. Thak you!
happy to help