SShortSingh.
Back to feed

React Query's staleTime and gcTime Explained: Two Settings, Two Jobs

0
·1 views

React Query has two commonly confused cache settings — staleTime and gcTime — that control entirely different aspects of data management. staleTime determines how long fetched data is considered fresh, preventing automatic background refetches during that window; it defaults to zero, meaning data is stale the moment it arrives. gcTime, formerly called cacheTime before v5, controls how long unused data lingers in memory after a component unsubscribes, defaulting to five minutes. Misusing these settings causes real bugs: setting staleTime to Infinity stops React Query from ever refetching on its own, while a long gcTime has no effect on how frequently active queries refresh. Developers are advised to treat the two as independent levers — one governing refetch frequency for active subscriptions, the other managing memory cleanup after components unmount.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Experiment Shows External Memory Can Restore Learned Behavior After Full Brain Reset

A developer built a small recurrent neural network paired with an external memory system to test whether learned experience could survive a complete substrate reset. The experiment used a fixed cue-response task where the network had to map specific inputs to correct actions, with chance performance at 33%. Results showed that external memory alone achieved near-perfect accuracy, while plasticity alone underperformed at roughly 47%, and combining both yielded 88%. Crucially, the memory system was constrained to only bias internal network states rather than directly select actions, preserving the integrity of the test. The key finding was that externally stored experience could reinstate correct behavior in a reset network that had never independently learned the task.

0
ProgrammingHacker News ·

Flock Safety Cameras Found to Contain Serious Security Flaws and Hardcoded Credentials

Security researcher Micah Lee has uncovered multiple vulnerabilities in Flock Safety's license plate recognition cameras, including hardcoded credentials embedded in the devices. These flaws could potentially allow unauthorized actors to gain access to the cameras or the data they collect. Flock Safety cameras are widely deployed by law enforcement agencies across the United States to monitor vehicle movements. The findings raise significant privacy and security concerns given the sensitive nature of the surveillance data these devices capture and store.

0
ProgrammingDEV Community ·

Installing Linux Packages Silently Runs Root Scripts You Never Audited

A software developer's routine installation of ffmpeg on a Linux machine prompted a deeper look at what package installation actually involves. Running apt install does far more than add a binary — it executes maintainer-written scripts as root, updates system databases, rewrites symlinks, drops config files into /etc, and triggers changes across dependencies. None of this process is sandboxed, meaning the user implicitly trusts the package maintainer and every upstream dependency with full system access. The author notes the greater risk lies not in obviously malicious packages but in routine, trusted ones that no longer attract scrutiny. The piece urges users and AI agents alike to treat any install command as a deliberate grant of root authority, not a harmless default action.

0
ProgrammingDEV Community ·

Critical Pre-Auth RCE Flaw Found in Fastjson 1.x; No Patch Available

A critical remote code execution vulnerability, tracked as CVE-2026-16723, has been disclosed in Fastjson versions 1.2.68 through 1.2.83, scoring as high as 9.8 on the CVSS scale. The flaw requires no authentication and exploits a trusted code path in the @JSONType annotation-handling branch, bypassing both AutoType and safeMode protections entirely. An attacker can host a malicious JAR file over plain HTTP and trigger execution simply by sending a crafted JSON payload to any endpoint calling JSON.parseObject(). Unlike previous Fastjson vulnerabilities, this exploit does not rely on known gadget classes or blacklisted type names, making existing defenses ineffective. Alibaba has declared Fastjson 1.x end-of-life and will not issue a patch, directing users to migrate to Fastjson2.