SShortSingh.
Back to feed

Stale-while-revalidate with Cache.match(): Serving Cached Responses While Refreshing Safely

0
·1 views

The article explains how to use Cache.match() or an equivalent store to return the last cached response immediately while refreshing the resource in the background. Clients are notified only after the new copy is successfully written, so the UI never claims freshness before the cache has actually changed. A compare-and-set rule based on timestamps, ETags, or versions prevents an older network response from overwriting a newer cached entry. The author provides a minimal in-memory runtime and tests covering immediate cache returns, network fallback storage, and refusal to overwrite fresher data. The piece also notes limitations, including that it does not exercise browser-specific APIs or full HTTP validation semantics.

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 ·

Unchanged 39-of-40 test score hid a shift in which CSV parser case failed

An AI developer built 40 CSV fixtures with literal expected results and ran them through the csv-parse 6.1.0 library via a custom policy adapter. Under default settings one quote-handling case disagreed with its expectation, and relaxing quote handling fixed that case but broke another, so the score stayed at 39 of 40. The author kept the expectations fixed and documented both mismatches, arguing that matching pass totals can conceal a changed behavior contract. The piece recommends recording file acceptance or rejection, exact returned values such as leading-zero identifiers, and parser configuration separately from application import policy. It also notes that the injected-fault and cross-implementation checks give only partial assurance and do not cover production databases or security.

0
ProgrammingDEV Community ·

How Social Engineering Exploits Human Psychology and How to Defend Against It

Social engineering is a cybersecurity threat that targets people rather than software, using psychological manipulation to get victims to reveal confidential information or take harmful actions. Attackers often gather information about their targets first to make their deceptions more believable. Common tactics include creating false emergencies that pressure victims into acting quickly, and pretexting, where the attacker impersonates a trusted authority such as IT staff or an executive. Physical methods like baiting, for example leaving infected USB drives in workplaces, also exploit curiosity to bypass technical defenses. The article uses concrete workplace scenarios to show how these manipulations operate and how individuals can recognize them.

0
ProgrammingDEV Community ·

Why a Typeahead Trie Should Store the Top 10 Completions at Every Node

A system design interview question about search autocomplete asks what a service does when a user types a single character. The naive approach of collecting and sorting every query under a prefix's subtree on each keystroke is correct but too slow at scale. Latency limits of about 0.1 seconds, including network time, make precomputation necessary. Illustrative capacity estimates show reads vastly outnumber writes and that client-side debouncing and caching can cut request volume roughly fourfold. The recommended fix is to precompute the top 10 completions at every trie node during build time, so each lookup only walks the prefix and returns a ready list.

0
ProgrammingDEV Community ·

Windows Paint Flaw CVE-2026-83844 Fix Not Reaching Some Systems Via Store Updates

Microsoft disclosed CVE-2026-83844, a remote code execution vulnerability in the built-in Windows Paint app, rated CVSS 8.1 and Important severity. The company lists version 11.2609.401.0 as the fixed release, which is delivered through the Microsoft Store rather than Windows Update. Multiple tests and IT administrator reports show that some systems with automatic Store updates enabled still run older Paint versions without receiving the fix. Microsoft's listing initially showed a different version number that appears to have been a typo, adding to user confusion. Users are advised to check their Paint version directly and consult Microsoft's current advisory, as the reason for the distribution gap has not been identified.