0PricingLogin
React Academy · Lesson

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

  1. Setting Up React Query & QueryClient
  2. Caching, Stale Time & Background Refetching
  3. Mutations with useMutation
  4. Infinite Scroll & Pagination with useInfiniteQuery
← Back to React Academy