when the values in the cache become invalidated and resync with the server state, the default configuration for most caches. cache-Control: public, max-age:60,s-maxage=60 This header instructs the browser not to make any further requests in the same URL within the next 60 seconds instead, it serves from the browser cache.
the problem we see is that React Query does not make requests, and it doesn't know about cache control headers. In React Query, there is a similar concept, which is staleTime.
The default staleTime is 0.
How does React Query know when to refetch data?
refetchOnMount: false refetchOnWindowFocus: false refetchOnReconnect: false
Garbage collection: A form of memory management where memory that has been allocated by a program will be automatically released after it is no longer i use. gcTime: 5
Will react query remove data from the cache after 5 minutes? No, as long as data is being actively used, it's not allowed to undergo Garbage collection.