Skip to content

Archive

Caching

36 articles
Tech 13 Sep 2026 6 min read

Browser Cookies and Cached Files Serve Different Jobs

A browser can remove cached images and scripts without signing you out of a website, yet clearing site cookies can end a signed-in session even when the page files remain stored locally. Both actions are often grouped under “clear browsing data,” but they affect different parts of browser state. Cookies and the HTTP cache solve separate problems. Cookies let a site associate small pieces of state with later requests. The cache lets a browser reuse eligible responses instead of transferring the same representation again whenever a page needs it.

Software Engineering 12 Sep 2026 10 min read

Request Coalescing at Hot Cache Misses

Request Coalescing at Hot Cache Misses A cache entry expires at 22:00:00.000. Ten milliseconds later, two hundred requests ask for the same key. A cache-aside implementation sees two hundred misses. If every caller independently reads the backing service, a single expiration event becomes two hundred concurrent backend operations. Nothing is wrong with the cache lookup itself. The amplification comes from treating identical in-flight work as unrelated. Request coalescing changes that boundary. Callers that need the same absent key share one active load, while requests for other keys continue independently. The mechanism is small, but its semantics reach beyond a mutex: it defines which operations may share a result, how failures fan out, what cancellation means, and when another load may begin.

Software Engineering 12 Sep 2026 10 min read

Cache Stampede Control with Early Refresh

Cache Stampede Control with Early Refresh A cache can remove enormous amounts of repeated work, yet a popular entry creates a sharp risk at expiry. If ten thousand requests depend on the same key and that key expires, many requests can discover the miss at nearly the same moment. Each request may then start the same database query, computation, or remote call. This event is commonly called a cache stampede. The cache works well during the entry lifetime, then abruptly stops protecting the dependency exactly when demand is high.

Tech 12 Sep 2026 5 min read

Browser Cache and Stale Web Files

A website can change on its server while one browser still shows an older image, script, or page response. Opening the same address in another browser may show the new version immediately. That difference often comes from the browser’s HTTP cache, which can reuse stored responses instead of downloading the same bytes again. The browser cache is not simply a folder of files that are either present or absent. HTTP gives cached responses a freshness state and provides validators that can check whether stored content still matches the server. Those rules determine when reuse avoids a network transfer and when the browser has to contact the server again.

Software Engineering 11 Sep 2026 9 min read

Cache-Aside Consistency: Prevent Stale Overwrites

Cache-Aside Consistency: Prevent Stale Overwrites Cache-aside is attractive because the application controls a simple protocol. A read checks the cache first. On a miss, it reads the database and places the result in the cache. A write updates the database and then invalidates or refreshes the cache. Each step is easy to describe. Concurrency makes the combined behavior less obvious. A delayed cache fill can publish an older database value after a newer write has already completed. The database remains correct, yet later readers can receive stale data from the cache. This article develops the race precisely and presents practical designs that keep an old fill from replacing a newer state.

Software Engineering 10 Sep 2026 8 min read

Stale-While-Revalidate for Responsive Caches

Stale-While-Revalidate for Responsive Caches A cache entry expires just as a request arrives. The cached value is still only seconds old, but the request now has to wait while the application fetches a replacement from a slower dependency. If many entries expire during a busy period, cache refreshes can turn a normally fast read path into a burst of slow work. Stale-while-revalidate changes that trade-off. For data that can safely be slightly out of date, the application may return an expired cached value immediately while refreshing it separately for future requests. The reader gets predictable latency, and the cache still moves toward fresh data.

Software Engineering 10 Sep 2026 11 min read

Negative Caching for Repeated Failures

Negative Caching for Repeated Failures Caching usually brings successful results to mind: load a value once, keep it for a while, and avoid repeating expensive work. But repeated failures can be just as expensive as repeated successes. Suppose a service receives thousands of requests for an object that does not exist. If every request queries the same downstream system, the absence of that object becomes a source of load. The same pattern appears with invalid identifiers, unavailable optional resources, failed name lookups, and other outcomes that are expensive to rediscover but unlikely to change immediately.

Tech 09 Sep 2026 8 min read

Why a Webpage Can Still Look Old After You Refresh It

You know a website has changed, but your browser still shows the old logo, an earlier image, or styling that should have disappeared. You press refresh, yet the page still does not look right. The usual explanation is caching: keeping a temporary copy of web content so it does not have to be transferred again every time it is needed. Caching makes ordinary browsing quicker and reduces unnecessary data transfer, but it also means that loading a page is not always the same as downloading every part of it again.

Artificial Intelligence 02 Sep 2026 5 min read

Semantic Caching for LLM Applications Without Serving Stale Answers

Large language model requests are expensive compared with ordinary cache lookups. When users repeatedly ask questions with slightly different wording, an exact string cache misses even though the intended answer may be identical. A semantic cache uses vector similarity to decide whether a new request is close enough to a previous request that its answer can be reused. The idea is attractive, but the difficult part is not storing embeddings. It is deciding when reuse is actually safe.

Web Development 02 Sep 2026 5 min read

HTTP Content Negotiation and Correct Vary Headers

One URL can sometimes represent the same resource in several formats. An API might return JSON or CSV, while a documentation endpoint might return HTML or plain text. HTTP content negotiation lets a client express which representation it can accept. The server chooses a response and tells caches which request headers influenced that choice. The second part is easy to miss: if the response changes based on a request header, shared caches need the correct Vary metadata.

Python 02 Sep 2026 4 min read

Cache Pure Work in Python with functools.cache and lru_cache

Caching can turn repeated expensive work into a dictionary lookup, but it can also return stale data or grow memory without bound. Python’s functools module provides two convenient memoization decorators: lru_cache and cache. functools.cache has been available since Python 3.9. It is effectively an unbounded memoization cache. lru_cache adds a configurable size limit and eviction behavior. Cache functions, not arbitrary side effects Memoization works best when a function behaves like a pure function: the result depends only on its arguments.

Web Development 01 Sep 2026 4 min read

HTTP Conditional Requests with ETag and Last-Modified

HTTP caching is not only about choosing a long max-age. Applications often need clients to revalidate data because a resource can change, while still avoiding retransmitting the full representation when it has not changed. HTTP validators solve that problem. The two common validators are ETag and Last-Modified. Freshness and validation are different A freshness directive can tell a cache that a response may be reused without contacting the server for a period: