DioxusLabs / DioxusLabs/dioxus
Client-side caching of server functions results
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Feature Request
Firstly, thanks for creating such a powerful framework!
In my Dioxus fullstack application, many requests, some of which are repeated over the same session are made by the client to the server. This leads to unnecessary, additional load on the server.
Caching would help in this case, particularly _client-side_ caching because:
- caches are client-specific
- it offloads cache resource from the server to the client
- it avoids networking latencies when fetching cached results, for a snappier user experience
---
Dioxus provides multiple hooks, each to varying effects.
The ones relevant for this discussion include:
- `use_memo`: Derive state from other states and memoizes the value.
- `use_resource`: Derive state from async closures, and changes when the future is updated.
- `use_server_future`: Similar to resource, but suspendible.
I'm looking for a hook that is a combination of `use_memo` and `use_server_future` — A hook that accepts a(n async) server function, and caches the `Ok(...)` variant of the result. (Maybe even the `Err(...)` as well, within a given time-to-live window).
#### Side Note
I came across [`use_server_cached`](https://dioxuslabs.com/learn/0.6/guides/fullstack/hydration#non-deterministic-data-with-server-cached) but that doesn't seem to work as it doesn't accept an async closure.
## Implement Suggestion
I'm not as familiar with Dioxus internals to provide a suggestion.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.