TanStackT
TanStack4mo ago
24 replies
dangerous-fuchsia

How can I tell if my query cache is being used successfully?

How can I tell if my query cache is being used successfully? If I set a staleTime of 60 minutes I still see it taking 110ms to complete if I navigate to another page/route and then come back (or just refresh the page).

Is it only saving me if my javascript on the same page was going to request again on some timer or does it save me on page loads like this?

const isAuthenticatedQuery = useQuery({
        queryKey: ['auth'],
        queryFn: async () => {
            const result = AuthenticationUtilities.isAuthenticated();
            return result;
        },
        staleTime: 60 * 60 * 1000, // 60 minutes
    });
Was this page helpful?