Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

If TanStack Query keeps requesting data that appears cached, the cache may be working as designed: cached data is considered stale immediately by default, and stale queries can refetch when an observer mounts, the window regains focus, or the device reconnects. The fix depends on what you see—repeated requests, outdated data after a mutation, data disappearing, or another fetch after hydration. Start by separating freshness from retention, then follow the matching checks below.

Why cached data can still trigger a request

TanStack Query’s documented default is that cached query data is stale immediately. Stale does not mean absent: the value can remain in the cache and render while the library refreshes it. A stale query may refetch when a new observer mounts, the window regains focus, or network connectivity returns. These are expected triggers, not necessarily signs that caching failed. See TanStack Query’s Important Defaults.

Two settings govern different parts of this behavior. staleTime sets how long data is treated as fresh; gcTime sets how long unused, inactive data stays in memory before garbage collection. Increasing gcTime can retain data longer, but it does not make stale data fresh or prevent a stale-driven refetch.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Setting or mechanism What it controls What to keep in mind
staleTime How long query data is considered fresh A longer window can reduce stale-driven refetches but may leave older data visible longer. Manual invalidation still matters with Infinity; 'static' blocks invalidation.
gcTime How long inactive query data is retained Longer retention uses memory for longer; it does not change freshness.
invalidateQueries Marks matching queries invalidated and normally refetches eligible matches Check the key, filters, and refetchType; disabled and static queries are exceptions.
Persistence maxAge and gcTime How long persisted data may be restored and retained in memory Align gcTime with or above maxAge when the restored cache should remain available for that period.
Query data and router loader data Separate state owners In TanStack Start, invalidate the owner that changed; if both changed, refresh both.

If a request repeats while the data is still visible

Check the query’s staleTime and identify which trigger coincides with the request: mounting, window focus, or reconnecting. Choose a freshness interval based on how quickly that data needs to reflect changes; there is no universally correct duration. TanStack Query’s guide says, “Setting staleTime is the recommended way to avoid excessive refetches.”

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

The same guide gives 2 * 60 * 1000 (two minutes) as an illustrative setting that can prevent refetches while data remains fresh, “or until the Query is invalidated manually.” This is an example, not a general recommendation. Set the value on the relevant query or in the appropriate defaults for your application.

Know the difference between staleTime: Infinity and staleTime: 'static' before choosing either. Infinity prevents data from becoming stale on a timer, but manual invalidation can still mark it stale and trigger a refetch. 'static' is stricter: the official defaults guide says invalidateQueries has no effect on static queries. It is intended for data that cannot change while the app is running, such as boot-time feature flags, permissions loaded at login, or static reference tables—not as a blanket way to suppress requests.

If data disappears after a component unmounts

Check gcTime. It applies after a query becomes inactive, rather than controlling whether an active query is fresh. TanStack Query’s documented default inactive retention is five minutes in the browser and Infinity on the server. These are documented defaults, not guarantees for every customized configuration. The QueryObserverOptions reference documents gcTime.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Increase gcTime if inactive data needs to remain available longer. When the query is used again, its freshness is still determined by staleTime, so retained data can render and then refetch if stale.

If a successful mutation leaves the screen showing old data

Verify that the mutation targets the intended query key and that the invalidation filters match the query you expect to refresh. invalidateQueries marks matching entries invalidated; unless refetchType: 'none' is specified, it refetches according to the filters, with active matches as the default selection. Invalidation does not remove the cached entry.

Inspect the filters and refetchType if the matching query remains unchanged. The QueryClient and Query references describe these APIs.

Rank #3
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

If the mutation returns the complete updated resource, TanStack Start’s guide notes that setQueryData can update the corresponding query cache entry directly. In a TanStack Start app, route loader data has a separate owner: router.invalidate() refreshes router-owned loader data and route context, while queryClient.invalidateQueries() handles Query data. Use both only when the mutation changes both kinds of state. See TanStack Query integration in TanStack Start.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If invalidation appears to do nothing

Check whether the query is disabled

When enabled: false, a query does not automatically fetch on mount or in the background, and it ignores invalidation or refetch calls that would otherwise trigger a fetch. TanStack Query’s Disabling/Pausing Queries guide states: “The query will ignore query client invalidateQueries and refetchQueries calls that would normally result in the query refetching.” Check whether a condition is keeping enabled false. The returned refetch method can trigger a fetch manually, subject to the documented skipToken limitation.

Check for static freshness

If the query uses staleTime: 'static', the Important Defaults guide says invalidation has no effect. Use that setting only when the data is genuinely static for the life of the app; otherwise choose a freshness policy that allows invalidation when updates need to appear.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

If another request happens after SSR or hydration

TanStack Query measures staleness from dataUpdatedAt using UTC timing. With the default staleTime of zero, server-provided data may already be stale when the page loads, so a background request after hydration can be expected. If that extra request is undesirable for the data in question, set a suitable higher staleTime. The Server Rendering & Hydration guide documents this behavior.

On the server, the documented default gcTime is Infinity. The SSR guide warns that setting gcTime: 0 may cause hydration errors if garbage collection removes data before rendering references it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For repeated reads immediately after hydration in TanStack Start, check whether server and client use matching query keys, whether hydration is configured as intended, and whether the application accidentally creates extra QueryClient instances. Also identify whether the data belongs to TanStack Query or to a router loader; refreshing one does not automatically refresh the other.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

If the persisted cache is discarded earlier than expected

Compare persistence maxAge with gcTime. The persistQueryClient guide says gcTime should be the same as or higher than maxAge if restored cache data should remain available for that period. A persistence buster string serves a different purpose: it lets an application intentionally discard cache from an outdated build or application state.

If prefetched data is followed by a component fetch

Prefetching uses the QueryClient’s default staleTime unless a per-call value is supplied. A staleTime set only for the prefetch operation does not automatically establish the component’s freshness policy. Configure staleTime on the subsequent useQuery as well when the component should treat the prefetched result as fresh for the intended interval. See Prefetching & Router Integration.

Verify the API against your installed version

The linked pages are TanStack’s current “latest” documentation, and the TanStack Start guidance applies to that integration. If your project uses an older TanStack Query major version or a different framework, confirm option names and behavior against the documentation for the installed version before applying an example.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.