Doctolib
Published in

Doctolib

React Query: cacheTime vs staleTime

Illustration by Vanko Yutian Zhou

If you ran upon this thread, you're probably struggling with setting up a great caching strategy using React Query (very recently renamed to TanStack Query). In this short article, I'll try to clarify the most common sources of confusion around cacheTime and staleTime, then conclude with a few opinionated recommendations as to how to use it with React Query.

Terminology

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Flavio Wuensche

Flavio Wuensche

196 Followers

Staff Engineer at Doctolib. Wanna be a climber. Regularly sharing short articles about React and Rails. twitter.com/fwuensche