fetchQuery staleTime returns cacheData in case of indexDB persister #9683
              
                Unanswered
              
          
                  
                    
                      bilalbhojani24
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 1 comment 11 replies
-
| 
         you can pass   | 
  
Beta Was this translation helpful? Give feedback.
                  
                    11 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
I’m using React Query with
@tanstack/query-persist-client-coreto persist cache data in IndexedDB. My setup creates a persister with a custom buster and IndexedDB storage, and it’s configured on theQueryClient. This works correctly—cached queries are restored when the app starts, and queries refetch if they’re stale according tostaleTime.The issue comes up on app mount when I run:
Since the data already exists in IndexedDB,
fetchQueryimmediately returns the cached value. But what I want is to always trigger a fresh API call on the first load, without considering the persisted cache.My idea is:- While hydrating first time make query stale always. Is this possible and recommended ?
CODE
Beta Was this translation helpful? Give feedback.
All reactions