What is the purpose of having `cacheTime` set to a higher value than `staleTime`?
When configuring options for a query (or globally), the
It seems like this configuration (or any configuration where
Conversely, it also seems pointless to have
It seems like these values should always be equal to each other.
cacheTime value controls how long data is kept in the in-memory cache before being garbage collected. The staleTime value controls how long cached data is considered fresh. Once this time expires, any requests will data will trigger a new fetch. By default, cacheTime is set to 5 minutes, and staleTime is set to 0 (meaning cached data is never fresh).It seems like this configuration (or any configuration where
cacheTime > staleTime) is kind of pointless. Why would you keep data persisted in the cache that you know is stale? Is there some scenario where having known-stale data provides a benefit over having the cache entry for that value be null?Conversely, it also seems pointless to have
cacheTime < staleTime, since in that scenario would result in cache misses for "fresh" data that had been garbage collected.It seems like these values should always be equal to each other.