Next.js Discord

Discord Forum

My data is not being revalidated every 60s.

Answered
Burmese posted this in #help-forum
Open in Discord
BurmeseOP
I am using the latest version of Nextjs and Reactjs
Answered by B33fb0n3
@Burmese thanks for sharing. Delete your .next folder. It looks like there is something cached that shouldn't be cached. So delete the .next folder.

After that it works fine like you can see here: https://codesandbox.io/p/devbox/testing-api-forked-7nh9vq?workspaceId=ws_U9MTFNwo3D8jjR8Ddi1Ynh
View full answer

24 Replies

BurmeseOP
Even I set the revalidate time to 1, did not work.
@Burmese Even I set the revalidate time to 1, did not work.
what happens? What do you see? What do you expect? How do you test it? ...
@B33fb0n3 what happens? What do you see? What do you expect? How do you test it? ...
BurmeseOP
I have one function for getting user data which is in action.ts file. This file has "use server" tags at the top. When I delete the user from api docs and come back to the website, I should expect to get new data. but What I am getting is the previous data.
plus I want the user data to be cached.
When setting a revalidate time like 1s or 60s, it is not updating the data.
ok. When you refresh again, do you see the new data?

So:
1. Actual data
2. Delete from api docs
3. Previous data is visible
4. what do you see here?
BurmeseOP
No, I keep refreshing the page, All I see is the old data.
When I remove the revalidate from next, it works fine, everytime it gives new data but I don't like that. The data must be cached.
can you remove the tag for a moment?
BurmeseOP
I tried but did not work.
which version of nextjs are you using?
BurmeseOP
^15.1.1
is your page itself statically or dynamically rendered?
BurmeseOP
Dynamically
can you create a reproduction of the problem? Like via [codesandbox.io](https://codesandbox.io/) or github.

As api endpoint you can use this one:
https://timeapi.io/api/time/current/zone?timeZone=Europe%2FAmsterdam
BurmeseOP
Yeah sure, one moment
There you go @B33fb0n3
The time is always going to be same. even though it has 10s revalidation time.
@Burmese thanks for sharing. Delete your .next folder. It looks like there is something cached that shouldn't be cached. So delete the .next folder.

After that it works fine like you can see here: https://codesandbox.io/p/devbox/testing-api-forked-7nh9vq?workspaceId=ws_U9MTFNwo3D8jjR8Ddi1Ynh
Answer
@Burmese Are you seeing new data every 10s?
Revalidation in general works like this:
1. Actual data
2. Delete from api docs (do something to change the data)
3. Previous data is visible -> Refetching in the background
4. New data is visible
And yes, I am seeing new data
BurmeseOP
Ok Thanks @B33fb0n3
happy to help