React · Senior · Question 50 of 75
When does RTK Query remove data from its cache?
- ✓Correct answer: When the data has no subscribers for longer than
keepUnusedDataFor(60 s by default) - 2Immediately after the last component unmounts, with no delay
- 3Never: data lives until the user reloads the page
Explanation
RTK Query counts hook subscriptions for each endpoint and argument. When no subscribers remain, the keepUnusedDataFor timer starts; if something subscribes again in that time, the data comes from the cache. The TanStack Query counterpart is gcTime.