CLOUD CONCEPT

Caching

Caching stores reusable copies of data or computed results closer to consumers or on faster storage to reduce retrieval time and repeated work.

Cloud Concepts Hub →

What is Caching

A cache serves repeated requests without always accessing the original data source or recomputing a result. In cloud architectures, caching can reduce latency, origin load, and data transfer, but it requires deliberate decisions about freshness, capacity, security, and failure behavior.

Caching places reusable data or results where they can be retrieved more efficiently than from their original source. The original source, often called the origin or system of record, normally remains authoritative. A cache might hold website images, database query results, application objects, or recently accessed file data. Its value comes from reuse: repeatedly reading the same information becomes faster or less expensive.

A cache hit occurs when the requested data is available and usable in the cache. A cache miss requires fetching the data from its source or computing it, often followed by storing it for subsequent requests. Hit ratio measures the proportion of requests served from the cache. A high hit ratio generally reduces source traffic, but performance also depends on object sizes, retrieval latency, and the overhead of looking up cached entries.

Cloud content delivery networks apply caching at edge locations distributed near users. For example, a user requesting a product image can receive a cached copy from a nearby edge location instead of retrieving it repeatedly from a distant application or storage origin. This reduces network travel time and origin requests. AWS edge locations support services such as Amazon CloudFront; they are not interchangeable with AWS Regions or Availability Zones, and they do not automatically cache every AWS workload.

Not every edge request is a cache hit. The requested object may be absent, expired, evicted, or configured not to be cached. The delivery service then retrieves it through its upstream path. Dynamic or personalized responses require particular care: caching a response under a key that does not distinguish users or relevant request attributes can expose one user's data to another. Cache policies must reflect the application's authorization and content variation requirements.

Hybrid storage uses the same principle in a different location. An on-premises gateway can retain frequently accessed cloud-backed file data on local disks. Applications continue using familiar file protocols while local cache hits avoid repeatedly downloading data across the wide-area network. Amazon S3 File Gateway, part of AWS Storage Gateway, provides NFS or SMB access to files stored as Amazon S3 objects and maintains a local cache. Writes are buffered locally and uploaded asynchronously, so monitoring upload progress and protecting local disks matter.

A local file cache does not imply that the complete dataset is available locally. Accessing uncached data requires connectivity to its backing storage, and disconnected operation is limited by cached content and gateway behavior. Also distinguish Storage Gateway cached volumes from stored volumes: cached volumes keep primary data in Amazon S3 with frequently accessed data cached locally, whereas stored volumes keep the complete primary volume locally and asynchronously back it up to AWS. These volume modes expose block storage, not file shares.

Freshness is a central trade-off. A time to live limits how long an entry is considered fresh, while invalidation explicitly removes or expires entries after a change. Neither approach should be assumed to provide immediate consistency across every cache. Versioned object names are useful for static assets because a new filename identifies new content without depending on immediate removal of the old copy.

Caches have finite capacity, so eviction policies remove entries to make room. Cold starts, mass expiration, or cache failure can suddenly increase load on the source; applications should tolerate misses and protect dependencies from request surges. Measure hit ratio, latency, evictions, source load, and total cost rather than assuming that a larger cache is always better. Finally, caching is not a backup strategy: cached copies may be incomplete, stale, or disposable, and pending writes require separate durability considerations.

Key aspects of Caching

Effective caching balances access speed and source-load reduction against freshness, capacity, security, and the consequences of misses or buffered writes.

Faster access through proximity

Place reusable data near consumers or on lower-latency storage. Edge caches shorten network paths for users, while local storage caches reduce repeated access across a wide-area connection.

Cache hits and misses

Hits avoid some or all source retrieval work; misses still require the source or an upstream cache. Measure hit ratio alongside latency and source traffic to determine whether caching helps the workload.

Freshness and invalidation

Expiration, explicit invalidation, and versioned identifiers control how cached data changes over time. Choose a strategy that matches how much stale data the application can tolerate.

Finite capacity and eviction

A cache usually holds a working set rather than the complete dataset. Size it for access patterns and monitor evictions, because frequently removing useful entries increases misses.

Write handling and durability

Some caches accelerate reads only, while others buffer writes before updating backing storage. With asynchronous writes, local acknowledgment does not necessarily mean the backing cloud store has received the data.

Isolation and failure behavior

Cache keys and access controls must prevent unintended sharing of private data. Plan for cold caches and outages so that sudden misses do not overwhelm the authoritative source.

Cloud services for Caching

These services apply caching at different points rather than forming a required stack. Amazon CloudFront caches eligible web content near users, AWS Storage Gateway keeps a local working set for hybrid storage access, and Amazon ElastiCache supports application-level reuse of data and results. A system can use several of these layers, but each needs its own freshness and failure strategy. Updating a database or cloud object does not automatically invalidate every cached representation, so engineers must coordinate expiration, invalidation, or versioning where the layers overlap.

Amazon CloudFront image Amazon CloudFront

Caches eligible HTTP content at distributed edge locations to serve users with lower latency and reduce origin requests. Cache keys, expiration settings, and invalidations determine what is reused and for how long.

Open Amazon CloudFront →
AWS Storage Gateway image AWS Storage Gateway

Provides hybrid storage capabilities, including Amazon S3 File Gateway, which caches cloud-backed file data locally for NFS or SMB access. Its Volume Gateway also offers cached volumes, which are block storage rather than file shares.

Open AWS Storage Gateway →
Amazon ElastiCache image Amazon ElastiCache

Provides managed in-memory caching using engines such as Valkey, Redis OSS, and Memcached. Applications can use it to reuse frequently requested data or computed results instead of repeatedly querying databases or performing expensive calculations.

Open Amazon ElastiCache →