Revalidate doesn't revalidate?
Unanswered
Alaskan Malamute posted this in #help-forum
Alaskan MalamuteOP
Hey!
So I have a function that returns random number and I wanted it to update max once every 30 seconds (just like ISR from the pages directory)
I tried this https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#example but it still didn't go as planned :v
Any help would be appreciated!
So I have a function that returns random number and I wanted it to update max once every 30 seconds (just like ISR from the pages directory)
I tried this https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#example but it still didn't go as planned :v
// functions/random.ts
export const random = () => {
return Math.random();
};// components/RawData.tsx
export const revalidate = 30;
import random from '@/functions/random'
export default async function RawData() {
console.log('revalidate???');
return <pre>{random()}</pre>;
}Any help would be appreciated!
6 Replies
European sprat
export const revalidate is for fetch requests to indicate when the cache is stale
Alaskan MalamuteOP
oh
European sprat
what you're seeing is "router cache"
Alaskan MalamuteOP
so if I can't use
revalidation, I need to somehow cache this data for 60 seconds right?European sprat
You can use router.refresh() which gets everything fresh from the server