Course contentsShow
← React
Lesson 1777 of 2,39642. Data Fetching LibrariesFree lesson

Request Deduplication Window

Understanding the deduplication timeframe and how concurrent requests are batched together.

Request Deduplication Window

You'll learn: How TanStack Query's deduplication window works to batch concurrent requests together within a specific timeframe.

The Timeframe for Deduplication

In the previous lesson, you learned that TanStack Query automatically deduplicates identical requests happening at the same time. But what does "same time" actually mean?

TanStack Query doesn't just deduplicate requests that fire in the exact same millisecond. Instead, it uses a deduplication window — a small timeframe (typically around 1 second by default) during which multiple identical requests get batched together.

How It Works

Think of it like an elevator: if three people press the call button within a few seconds of each other, the elevator doesn't make three separate trips. It waits briefly, collects everyone, and makes one efficient journey.

Similarly, if:

  • Component A mounts and triggers useQuery(['user', 1])
  • 200ms later, Component B mounts and triggers the same query
  • 500ms later, Component C also requests ['user', 1]

All three components will receive data from the same network request because they fell within the deduplication window.

Why This Matters

This window handles real-world timing issues:

  • Components mounting in rapid succession (but not perfectly synchronized)
  • Fast navigation where route changes trigger similar queries
  • Race conditions where logic fires "almost" simultaneously

Without this window, you'd need perfect timing synchronization, which is impossible in practice. The deduplication window gives you a reasonable grace period where TanStack Query intelligently combines requests.

Key Takeaway: TanStack Query's deduplication window (~1 second by default) batches identical requests that occur close together in time, not just at the exact same moment, making deduplication practical for real-world component mounting and navigation patterns.