how to revalidate a cached function (get some data in the db using cache(...) ) ?
Answered
American Crocodile posted this in #help-forum
American CrocodileOP
revalidate a cached function (get some data in the db using cache(...) )
17 Replies
revalidatePath()
American CrocodileOP
i've try to call revalidatePath() with a fetch, it does not work
Then that means revalidatePath() is buggy or you did it incorrectly
American CrocodileOP
Looks sus, shouldn’t it be /api/revalidate with a slash at the front
American CrocodileOP
it does not throw an error ?
(im a newbie sorry)
This did console.log correctly right
With path being the correct path and all
American CrocodileOP
hey it does
Then revalidatePath is buggy i think
Though it works for me
American CrocodileOP
American CrocodileOP
looks like it does work with this
Answer
American CrocodileOP
(server actions)
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?