-
I'm reading the documentation and different guides and articles, and I can't still figure out why'd I wan't to control this, and it causing some confusion on the dev team (especially it's old name was cacheTime and a migration guide said to simply change it's name). If I'm understanding correctly staleTime is the one I care about. gcTime would kick in after data becomes unused, why would I want to control that? why would any value except "as soon as possible" make sense? is there a use case or example when this is useful? thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Beta Was this translation helpful? Give feedback.
staleTime
controls how long it takes until data is considering stale and eligible for background refetching while the stale data is shown. Background refetching happens among others when a new query with the same key is added or the browser window / tab regains focus. If thestaleTime
is increased background refetches will occur less often as data would be considered fresh for longer.gcTime
controls how long data remains in the cache until it's automatically removed. Depending on your application at some time data may become too old to even show while new data is fetched. Or the other way around it may make sense to show quite old data while refetching. As this depends completely on the …