Nitro-SWR-Reval-on-Demand #716
raven-dever
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
One thing I am unsure of is if the cached .json file always follows this schema in all storage drivers and environments: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have written two util-functions that solve (imo) an important use-case:
Easy on-demand revalidition of cached/swr handlers.
From the docs there isn't a clear-cut easy access to cached routes with useStorage and then refreshing the payload seems to require complete desctruction of the cache-value with useStorage.removeItem()
https://stackblitz.com/edit/github-xc6cjm-tjfbvf?file=utils/swrRevalidate.ts
createSwrCache({name, group}) -> creates a storage key-value pair instance
revalidateSwrCache ({ name, group, route, }) -> destroys storage key-value pair instance and makes an automatic request to refresh the data from the passed-in route
Beta Was this translation helpful? Give feedback.
All reactions