My data is not being revalidated every 60s.
Answered
American Shorthair posted this in #help-forum
American ShorthairOP
I am using the latest version of Nextjs and Reactjs
Answered by B33fb0n3
@American Shorthair thanks for sharing. Delete your
After that it works fine like you can see here: https://codesandbox.io/p/devbox/testing-api-forked-7nh9vq?workspaceId=ws_U9MTFNwo3D8jjR8Ddi1Ynh
.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
24 Replies
American ShorthairOP
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? ...
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.
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?
So:
1. Actual data
2. Delete from api docs
3. Previous data is visible
4. what do you see here?
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.
can you remove the tag for a moment?
American ShorthairOP
I tried but did not work.
which version of nextjs are you using?
American ShorthairOP
^15.1.1
is your page itself statically or dynamically rendered?
American ShorthairOP
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
As api endpoint you can use this one:
https://timeapi.io/api/time/current/zone?timeZone=Europe%2FAmsterdam
American ShorthairOP
Yeah sure, one moment
American ShorthairOP
There you go @B33fb0n3
The time is always going to be same. even though it has 10s revalidation time.
@American Shorthair thanks for sharing. Delete your
After that it works fine like you can see here: https://codesandbox.io/p/devbox/testing-api-forked-7nh9vq?workspaceId=ws_U9MTFNwo3D8jjR8Ddi1Ynh
.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
American ShorthairOP
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
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
American ShorthairOP
Ok Thanks @B33fb0n3
happy to help