how to revalidate a cached function (get some data in the db using cache(...) ) ?
Answered
American Crocodile posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
American CrocodileOP
revalidate a cached function (get some data in the db using cache(...) )
17 Replies
![Avatar](https://cdn.discordapp.com/avatars/484037068239142956/f386ac21405ce3442e0f3598223e1cb3.webp?size=256)
joulev
revalidatePath()
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
American CrocodileOP
i've try to call revalidatePath() with a fetch, it does not work
![Image](https://cdn.discordapp.com/attachments/1121012570397102191/1121013168655839232/image.png)
![Avatar](https://cdn.discordapp.com/avatars/484037068239142956/f386ac21405ce3442e0f3598223e1cb3.webp?size=256)
joulev
Then that means revalidatePath() is buggy or you did it incorrectly
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
American CrocodileOP
![Image](https://cdn.discordapp.com/attachments/1121012570397102191/1121013242488160306/image.png)
![Avatar](https://cdn.discordapp.com/avatars/484037068239142956/f386ac21405ce3442e0f3598223e1cb3.webp?size=256)
joulev
Looks sus, shouldn’t it be /api/revalidate with a slash at the front
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
American CrocodileOP
it does not throw an error ?
(im a newbie sorry)
![Avatar](https://cdn.discordapp.com/avatars/484037068239142956/f386ac21405ce3442e0f3598223e1cb3.webp?size=256)
joulev
This did console.log correctly right
With path being the correct path and all
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
American CrocodileOP
hey it does
![Avatar](https://cdn.discordapp.com/avatars/484037068239142956/f386ac21405ce3442e0f3598223e1cb3.webp?size=256)
joulev
Then revalidatePath is buggy i think
Though it works for me
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
American CrocodileOP
![Image](https://cdn.discordapp.com/attachments/1121012570397102191/1121013542594809876/image.png)
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
American CrocodileOP
looks like it does work with this
![Image](https://cdn.discordapp.com/attachments/1121012570397102191/1121021395690864752/image.png)
Answer
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
American CrocodileOP
(server actions)
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Manx
There is so little information on the web regarding how cache() works. So does cache only de-duplicate functions per path? I have a lot of API calls through a library that could be deduplicated on an authenticated page (so it renders dynamically depending on the logged in user), but the data could be refreshed updated externally. My questions are:
- I created a function that deduplicates based on some key (e.g. id: 1) as the parameter, is this deduplicated between requests for this data from different users?
- If the function is also used in other paths, when calling revalidate, does it revalidate all the cache of the function for all routes that depend on it?
- I created a function that deduplicates based on some key (e.g. id: 1) as the parameter, is this deduplicated between requests for this data from different users?
- If the function is also used in other paths, when calling revalidate, does it revalidate all the cache of the function for all routes that depend on it?