Least Recently Used
/ˌɛl ɑː ˈjuː/
noun — "evict the item not used for the longest time."
LRU, short for Least Recently Used, is a cache replacement and resource management policy that discards the item whose last access occurred farthest in the past when space is needed. It is based on the assumption that data accessed recently is more likely to be accessed again soon, while data not accessed for a long time is less likely to be reused. This principle aligns closely with temporal locality, a common property of real-world workloads.
Technically, LRU defines an ordering over cached items based on recency of access. Every read or write operation updates the position of the accessed item to mark it as most recently used. When the cache reaches capacity and a new item must be inserted, the item at the opposite end of this ordering, the least recently accessed one, is selected for eviction. The challenge in implementing LRU lies not in the policy itself, but in maintaining this ordering efficiently under frequent access.
Common implementations of LRU combine a hash table with a doubly linked list. The hash table provides constant-time lookup to locate cached entries, while the linked list maintains the usage order. On access, an entry is moved to the head of the list. On eviction, the tail of the list is removed. This approach achieves O(1) time complexity for insert, delete, and access operations, at the cost of additional memory overhead for pointers and bookkeeping.
In systems where strict LRU tracking is too expensive, approximations are often used. Operating systems, databases, and hardware caches may implement variants such as clock algorithms or segmented LRU, which reduce overhead while preserving similar behavior. For example, page replacement in virtual memory systems frequently uses an LRU-like strategy to decide which memory pages to swap out when physical memory is exhausted.
Operationally, LRU appears across many layers of computing. Web browsers use it to manage in-memory caches of images and scripts. Databases use it for buffer pools that cache disk pages. Filesystems apply it to inode or block caches. CPU cache hierarchies rely on approximations of LRU to decide which cache lines to evict. In each case, the goal is the same: keep the working set resident and minimize expensive fetches from slower storage.
A simplified conceptual implementation looks like this:
# access(key):
# if key exists:
# move key to front of list
# else:
# if cache is full:
# evict key at end of list
# insert key at front of list
This model highlights the essential behavior without committing to a specific data structure or language. Real implementations must also handle concurrency, memory constraints, and consistency guarantees.
In practice, LRU performs well for workloads with strong temporal locality but can degrade under access patterns that cycle through large working sets slightly larger than the cache capacity. In such cases, frequently accessed items may still be evicted, leading to cache thrashing. For this reason, LRU is often combined with admission policies, frequency tracking, or workload-specific tuning.
Conceptually, LRU is like clearing space on a desk by removing the item you have not touched in the longest time, on the assumption that what you used most recently is what you are most likely to need again.
See Cache, FIFO, Page Replacement.
CDN
/ˌsiː-diː-ˈɛn/
n. “A network that delivers content at the speed of thought.”
CDN, or Content Delivery Network, is a distributed network of servers strategically placed across the globe to deliver web content—such as HTML pages, images, videos, and scripts—quickly and reliably to users, regardless of their location. Instead of all requests going to a single origin server, a CDN caches content at edge locations, reducing latency, load times, and the chance of downtime.
By bringing content closer to the end user, CDN technology improves user experience, reduces bandwidth costs, and enhances scalability. For example, a website hosted in New York can serve a user in Tokyo almost as fast as a local server because the CDN edge node near Tokyo delivers the cached content instantly.
CDNs are critical for high-traffic websites, streaming services, and global applications. They help mitigate the impact of sudden traffic spikes and protect against attacks like DDoS by distributing requests across multiple servers. Popular providers, such as Cloudflare, Akamai, and Fastly, offer additional features like SSL termination, caching rules, analytics, and security protections that integrate with standard protocols and cryptographic measures like HMAC or SHA256.
A practical example: if you deploy a new version of a web app, the CDN ensures that users worldwide see updated assets without overwhelming your origin server. Similarly, video platforms serving millions of simultaneous streams rely on CDNs to avoid buffering and downtime.
CDNs also contribute to SEO and site performance. Search engines factor in page load times and uptime reliability; distributing content efficiently improves both. For developers and system architects, implementing a CDN is a fundamental step in creating a robust, global-ready web application.
In short, a CDN is more than just a caching system—it’s the backbone of modern web performance, a shield against network issues, and a facilitator of seamless user experiences across geographies. In combination with secure hashing, authentication, and encryption standards like MD5, SHA256, or HMAC, it ensures that content is delivered fast, reliably, and safely.