Skip to content

staleTime vs cacheTime #1685

Answered by TkDodo
hosseinmd asked this question in Q&A
Jan 24, 2021 · 6 comments · 20 replies
Discussion options

You must be logged in to vote

It does get people confused sometimes, which is why I tried to clear that up in a blog post: https://tkdodo.eu/blog/practical-react-query#the-defaults-explained

StaleTime: The duration until a query transitions from fresh to stale. As long as the query is fresh, data will always be read from the cache only - no network request will happen! If the query is stale (which per default is: instantly), you will still get data from the cache, but a background refetch can happen under certain conditions.

CacheTime: The duration until inactive queries will be removed from the cache. This defaults to 5 minutes. Queries transition to the inactive state as soon as there are no observers registered,…

Replies: 6 comments 20 replies

Comment options

You must be logged in to vote
3 replies
@ibadeeCodes
Comment options

@TkDodo
Comment options

@mikib0
Comment options

Answer selected by hosseinmd
Comment options

You must be logged in to vote
3 replies
@TkDodo
Comment options

@lukemorales
Comment options

@TkDodo
Comment options

Comment options

You must be logged in to vote
3 replies
@TkDodo
Comment options

@SAURABH0504
Comment options

@TkDodo
Comment options

Comment options

You must be logged in to vote
2 replies
@TkDodo
Comment options

@patricklafrance
Comment options

Comment options

You must be logged in to vote
1 reply
@TkDodo
Comment options

Comment options

You must be logged in to vote
8 replies
@syNack0
Comment options

@TkDodo
Comment options

@syNack0
Comment options

@TkDodo
Comment options

@syNack0
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet