Skip to content

staleTime vs cacheTime #1685

Answered by TkDodo
hosseinmd asked this question in Q&A
Jan 24, 2021 · 7 comments · 22 replies

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: 7 comments 22 replies

You must be logged in to vote
5 replies
@ibadeeCodes

@TkDodo

@mikib0

@markomitranic

@TkDodo

Answer selected by hosseinmd

You must be logged in to vote
3 replies
@TkDodo

@lukemorales

@TkDodo

You must be logged in to vote
3 replies
@TkDodo

@SAURABH0504

@TkDodo

You must be logged in to vote
2 replies
@TkDodo

@patricklafrance

You must be logged in to vote
1 reply
@TkDodo

You must be logged in to vote
8 replies
@syNack0

@TkDodo

@syNack0

@TkDodo

@syNack0

You must be logged in to vote
0 replies
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet