DEV Community

DevScriptor
DevScriptor

Posted on

Types of Cache Used in System Design and Architecture

Types of Cache: Overview, Use Cases, and Examples

Caching can be implemented in various layers of a system. Here's a breakdown of the main types of cache, categorized by where and how they are used:

1. Client-Side Cache
Definition: Data is cached on the user's device (browser or app).
Use Case: Store static assets, user preferences, session data.
Benefits:

  • Reduces server load.
  • Improves perceived performance and load times.

Examples:

  • Browser cache (HTML, CSS, JS).
  • Service workers using IndexedDB or localStorage.
  • HTTP caching headers (Cache-Control, ETag).

2. Server-Side Cache
Definition: Data is cached on the backend server.
Use Case: Cache API responses, authentication tokens, templates.
Benefits:

  • Reduces computation and DB queries.
  • Faster response for repeat requests.

Examples:

  • Node.js or Django in-memory cache.
  • Redis or Memcached integrated into the app logic.

3. Database Cache
Definition: Frequently accessed database queries or results are cached.
Use Case: Speed up slow or expensive DB queries.
Benefits:

  • Reduces read load on the database.
  • Improves latency for complex joins or aggregations.

Examples:

  • Redis used to store query results.
  • Materialized views in SQL databases.
  • Query result caching in PostgreSQL or MySQL.

4. Content Delivery Network (CDN) Cache
Definition: Caches static and dynamic content at edge locations near users.
Use Case: Serve images, videos, and static files quickly worldwide.
Benefits:

  • Low latency, high availability.
  • Offloads origin server.

Examples:

  • Cloudflare, Akamai, AWS CloudFront.

5. Application-Level Cache
Definition: Cache implemented within the application layer for specific logic.
Use Case: Caching method results, configuration, business logic.
Benefits:

  • Fine-grained control over what gets cached.
  • Can be memory-efficient.

Examples:

  • Spring Boot caching annotations.
  • Python decorators using functools.lru_cache.

6. Distributed Cache
Definition: Cache that spans multiple nodes/machines, shared across a cluster.
Use Case: Scalability for large, high-throughput systems.
Benefits:

  • High availability and horizontal scaling.
  • Can support replication, sharding.

Examples:

  • Redis Cluster.
  • Hazelcast, Apache Ignite.

7. Page Cache / Full Page Cache (FPC)
Definition: Entire HTML pages are cached to serve without re-rendering.
Use Case: E-commerce platforms, CMS websites.
Benefits:

  • Dramatically improves page load time.
  • Reduces backend workload.

Examples:

  • Magento Full Page Cache.
  • Varnish Cache.

8. Operating System (OS) Cache
Definition: OS caches frequently used disk blocks or file system data.
Use Case: Speed up file system access, reduce disk I/O.
Benefits:

  • Transparent to the user/app.
  • Improves performance of frequently used files.

Examples:

  • Linux Page Cache.
  • Windows Disk Cache.

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.