Home

Caches

A cache is a storage layer that holds copies of data from a slower primary store to reduce access time. They exploit temporal and spatial locality to serve many requests quickly rather than fetching from the slower source.

In hardware, CPU caches are small, fast memory near the processor, typically organized into levels such as

A cache hit occurs when requested data is found in the cache; a miss requires fetching from

Software caches store results of expensive operations or web resources to improve performance. Examples include memoization,

Caching requires managing data validity and coherence. Invalidation, expiration, and cache warming are common concerns, as

L1,
L2,
and
L3.
L1
is
fastest
and
smallest,
often
split
into
instruction
and
data
caches.
Caches
use
properties
such
as
inclusivity
or
exclusivity,
write-back
or
write-through
policies,
and
set
associativity
with
cache
lines.
In
multi-core
systems,
cache
coherence
protocols
(such
as
MESI)
maintain
consistency
across
caches.
the
next
slow
tier.
Misses
are
classified
as
compulsory,
capacity,
or
conflict.
Performance
is
summarized
by
the
hit
rate
and
miss
penalties,
and
depends
on
the
replacement
policy
(LRU,
LFU,
FIFO)
and
cache
size.
database
query
caches,
and
web
caches
such
as
browser
caches,
proxies,
and
content
delivery
networks.
HTTP
caching
uses
headers
like
Cache-Control,
Expires,
ETag,
and
Last-Modified
to
control
freshness
and
validation.
are
security
and
privacy
considerations
when
caching
sensitive
data.
Properly
designed
caches
can
dramatically
reduce
latency
and
conserve
bandwidth
while
maintaining
acceptable
data
freshness.