-
Hello, I'm really excited about some of the improvements the We've found that in some cases our persisted cache causes confusion for users/developers when data is unexpectedly cached. I'd like to add a "Clear Cache" function that I can expose to flush the cache. I've read the Beta docs (that I believe are most relevant) and poked around the code looking for things that might be less documented and haven't found a solution to get there. For context: I've created a Things I've tried
Minimal ReproductionAll of the above attempts are included in this sandbox: https://stackblitz.com/edit/nextjs-vgdtql?file=components/Example.js You can watch the 5 numbers load in delayed if the cache is removed from localStorage, here's a small recording of myself starting with a cache, clearing it with my signature wait a few seconds and clear things strategy: View recordingCleanShot.2022-07-06.at.18.00.42.mp4Other ideas that seem possible?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Okay I found the answer and I feel silly that it took writing out all of this and going through so many attempts to get it right, but have learned a lot about the inner workings in the process! Turns out since the cache comes from the
|
Beta Was this translation helpful? Give feedback.
Okay I found the answer and I feel silly that it took writing out all of this and going through so many attempts to get it right, but have learned a lot about the inner workings in the process!
Turns out since the cache comes from the
queryClient
that is in memory, my last idea listed in my original post is actually correct, I can simply wipe the client and let it write the new empty store to the persisted cache like so: