Cache in NextJS 14.1.4 and 14.2
Unanswered
Spectacled bear posted this in #help-forum
Spectacled bearOP
Hello, I'm trying to do some basic stuff like todo app.
I'm using prisma and server actions.
I use next 14.1.4 and I'm adding some task (item) by form action, there I'm adding data to database and revalidatePath('/'), under form i wanna have client component that keep data from useState even if i revalidatePath, it works. Even if i revalidate path every keep state.
In 14.1.4 it works, but in 14.2.4 after first form action it reload whole data, after second, and each it work like 14.1.4, why?
I'm using prisma and server actions.
I use next 14.1.4 and I'm adding some task (item) by form action, there I'm adding data to database and revalidatePath('/'), under form i wanna have client component that keep data from useState even if i revalidatePath, it works. Even if i revalidate path every keep state.
In 14.1.4 it works, but in 14.2.4 after first form action it reload whole data, after second, and each it work like 14.1.4, why?
23 Replies
Spectacled bearOP
bump
Show your code and record the issue @Spectacled bear
Spectacled bearOP
In 14.2 at first action it remove state value under form
@Arinji
I know that in 14.2 there is update of cache but i don't understand it
Can you send the code for the like rendering of state and the onSubmit event handler
Spectacled bearOP
if it will be easier i'm sending /src
Turkish Angora
It is because you cannot cache fetch in 14.2.x when you are doing it with a dynamic page.
Right now, I’m staying on 14.1.4
Right now, I’m staying on 14.1.4
If you build your project you will probably see a lambda function next to your page
I don’t know why they have changed the behavior of cache like that…
Spectacled bearOP
but in 15 rc it is the same, so i do you have any solution to keep this state?
and why after first submit it keep it
Turkish Angora
Un 15rc you can combined static and dynamic page with suspense
Maybe you should investigate about that
I didn’t not try on nextjs15, too risky for me right now
Turkish Angora
So I have found a way to do it
Use unstable_cache instead and read the good to know
Working very well for 14.2.4 with dynamic function
Dynamic page *