Skip to content

Clarification on why gcTime is needed or what purpose it serves #8702

Closed Answered by arnoud-dv
pablote asked this question in Q&A
Discussion options

You must be logged in to vote

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 the staleTime 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 …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TkDodo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants