Caching, Stale Time & Background Refetching
Configure staleTime and gcTime to control when data is re-fetched from the server.
Welcome
In this lesson you will configure staleTime and gcTime to control how long React Query keeps data fresh and how long it retains cached data in memory.
Fresh vs Stale Data
React Query tracks whether cached data is 'fresh' or 'stale'. Fresh data is returned immediately without a network request. Stale data is returned immediately but a background refetch starts to update it.
All lessons in this course
- Setting Up React Query & QueryClient
- Caching, Stale Time & Background Refetching
- Mutations with useMutation
- Infinite Scroll & Pagination with useInfiniteQuery