CachingStrategy
A mechanism to finely adjust the behavior of the query results on a component basis in Composable functions.
In addition to the default behavior provided by Stale-While-Revalidate, two experimental strategies are now available:
Cache-First: This strategy avoids requesting data re-fetch as long as valid cached data is available. It prioritizes using the cached data over network requests.
Network-First: This strategy maintains the initial loading state until data is re-fetched, regardless of the presence of valid cached data. This ensures that the most up-to-date data is always displayed.
Background: During in-app development, there are scenarios where returning cached data first can lead to issues. For example, if the externally updated data state is not accurately reflected on the screen, inconsistencies can occur. This is particularly problematic in processes that automatically redirect to other screens based on the data state.
On the other hand, there are situations where data re-fetching should be suppressed to minimize data traffic. In such cases, setting a long staleTime in QueryOptions is not sufficient, as specific conditions for reducing data traffic may persist.