Next.js Discord

Discord Forum

My data is not being revalidated every 60s.

Answered
American Shorthair posted this in #help-forum
Open in Discord
Avatar
American ShorthairOP
I am using the latest version of Nextjs and Reactjs
Image
Answered by B33fb0n3
@American Shorthair 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

Avatar
American ShorthairOP
Even I set the revalidate time to 1, did not work.
Avatar
what happens? What do you see? What do you expect? How do you test it? ...
Avatar
American ShorthairOP
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.
Avatar
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?
Avatar
American ShorthairOP
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.
Avatar
can you remove the tag for a moment?
Avatar
American ShorthairOP
I tried but did not work.
Avatar
which version of nextjs are you using?
Avatar
American ShorthairOP
^15.1.1
Avatar
is your page itself statically or dynamically rendered?
Avatar
American ShorthairOP
Dynamically
Avatar
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
Avatar
American ShorthairOP
Yeah sure, one moment
Avatar
American ShorthairOP
There you go @B33fb0n3
The time is always going to be same. even though it has 10s revalidation time.
Avatar
@American Shorthair 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
Avatar
American ShorthairOP
Are you seeing new data every 10s?
Avatar
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
Avatar
American ShorthairOP
Ok Thanks @B33fb0n3
Avatar
happy to help