Next.js Discord

Discord Forum

Revalidate not working

Unanswered
nohaxito posted this in #help-forum
Open in Discord
Any idea of why revalidate is not working? Im using next 13.5.2

49 Replies

Can you give more information why its not working? @nohaxito
wdym with "why its not working"?
how did you find out, what behavior did you expect, what happened instead
- ¿how did you find out?
Well, an application which fetches my backend to return files from a directory, when I create a new file from my frontend it is not shown until I manually refresh the page.
- what behavior did you expect?
Que la data que recibo desde el fetch se vaya revalidando para evitar tener que refrescar la pagina
- what happened instead?
Nothing
you might want to manually trigger refresh by using router.refresh()
Yes, it was the only solution I could implement.
But what seems strange to me is that in previous versions (< 13.3) it worked perfectly.
well fetch() wont get called if you dont send response to the server again
try cache: 'no-store' instead of reavlidate 0
ok, i will try
nah, isn't working
I heard someone reporting this issue twice already (though with a positive value for revalidate)
Yes; one reported that it didn’t work for revalidate: 5, the other 10
But for both cases it works fine in 13.4.19
in dev not working, i will try in prod mode.
prod also not working
can you describe the user interaction?
here, the user select a file(s) and submit form
in the submit function this fetch is executed:
and closes the dialog
so it doesn't hit Next.js server when submitting?
api route?
@nohaxito in the submit function this fetch is executed:
whats after await fetch?
@aardani whats after `await fetch`?
check if the backend return success or error
if success closes the dialog and shows a toast
if error dont close the dialog and shows a toast
so it doesnt hit Next.js server?
@nohaxito Any idea of why revalidate is not working? Im using next 13.5.2
this code only runs if you hit Next.js server. It does not trigger if your front end uploads a new file
thats why you have to router.refresh()
@aardani so it doesnt hit Next.js server?
wdym with hit next.js server?
the "api routes"?
send request to Next.js server. Either by api routes or through server components
oh, ok i will try tomorrow
client components cannot send data back to server component without making another request
thats why you have to router.refresh() or just update the UI in the client component
@aardani thats why you have to `router.refresh()` or just update the UI in the client component
So, which part i need to request to the nextjs server?
the recovering files fetch or upload fetch?
@nohaxito the recovering files fetch or upload fetch?
After the file is uploaded, you need to refresh to trigger the rerender
If you dont want to do that then you can opt into optimistic refebdering which takes a bit more effort to set up
I'm referring to the part where it says to sent request to the next.js server
this request?
or this request
What is backend_api_url?
@aardani What is backend_api_url?
a url to my custom backend
So what seems to be the problem?