Revalidate not working
Unanswered
nohaxito posted this in #help-forum
49 Replies
nohaxitoOP
Can you give more information why its not working? @nohaxito
nohaxitoOP
wdym with "why its not working"?
how did you find out, what behavior did you expect, what happened instead
nohaxitoOP
- ¿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
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()nohaxitoOP
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 againtry
cache: 'no-store' instead of reavlidate 0nohaxitoOP
ok, i will try
nohaxitoOP
nah, isn't working
I heard someone reporting this issue twice already (though with a positive value for revalidate)
@joulev I heard someone reporting this issue twice already (though with a positive value for revalidate)
nohaxitoOP
with the revalidate const?
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
nohaxitoOP
in dev not working, i will try in prod mode.
prod also not working
can you describe the user interaction?
in the submit function this fetch is executed:
and closes the dialog
so it doesn't hit Next.js server when submitting?
nohaxitoOP
api route?
@nohaxito in the submit function this fetch is executed:
whats after
await fetch?@aardani whats after `await fetch`?
nohaxitoOP
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?
nohaxitoOP
wdym with hit next.js server?
the "api routes"?
send request to Next.js server. Either by api routes or through server components
nohaxitoOP
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
nohaxitoOP
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?
nohaxitoOP
a url to my custom backend
So what seems to be the problem?