React · Middle · Question 42 of 75

How does staleTime differ from gcTime in TanStack Query?

Explanation

While data is fresh, there's no refetch on mount or window focus. After staleTime, it becomes stale but is still shown from the cache and refreshed in the background. gcTime (formerly cacheTime, 5 minutes by default) starts counting when the query has no observers left - then the data is removed from memory.

Further reading

Problem with a question

React · Middle · question 42

Test yourself

Take the React · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz