liveBook · Manning

Caching

As explained in Acing the Frontend Interview

Database caching uses database-internal cached data or query results to reduce repeated storage access and accelerate reads.

Caching stores frequently accessed data or query results closer to the user or compute layer, reducing repeated storage access, latency, and backend pressure. Database caching is one layer within a broader system-design strategy. section 6.4

Evaluate caching by layer and trade-off:

  • Client-side caches store assets and some API responses, avoiding network requests but requiring careful versioning. section 6.4
  • CDN caches serve static or computed content from edge locations, reducing origin work while making expiration and purging important. section 6.4
  • Application-level caches keep sessions, tokens, profiles, or product listings in memory, reducing database load and response time. section 6.4
  • Compare speed and backend relief against consistency, invalidation complexity, distributed coordination, and the possibility of stale data. section 6.4

Interview framing

When asked how caching improves a read-heavy architecture, describe storing frequently accessed data near the user or compute layer, then explain the chosen layer, expiration or invalidation policy, and consistency risks. section 6.4

Table 6.5 Caching strategies
Topic
Fundamentals
Applied skills
Advanced
In-memory caches
Understand key-value storage (e.g., Redis, Memcached). Use TTLs (Time To Live) and LRU (Least Recently Used).
Cache sessions, tokens, and user profiles. Use cache-aside or write-through strategies.
Implement eviction policies, handle cache stampedes, and tune Redis clustering or persistence.
Client-side caching
Know how browsers use localStorage, sessionStorage, IndexedDB, and HTTP caching headers.
Control asset and API caching with Cache-Control, ETag, and Last-Modified.
Implement service workers, stale-while-revalidate, and offline-first strategies for PWA-like resilience.
CDN caching
Understand what a CDN is and how it caches static content at edge nodes.
Configure HTTP headers for control ( Cache-Control, ETag, Expires). Use Cloudflare, CloudFront.
Apply edge-side includes (ESI), handle cache purges, and tune stale content policies for dynamic content.
Application- level caching
Use in-process caches (e.g., LRU). Avoid repeated function calls.
Use decorators ( @Cacheable), middleware, or sidecar caches. Cache expensive computations.
Design multi-tiered caches across services. Use memoization with TTLs and dependency-based invalidation.
Database caching
Understand in-memory query result caching, buffer pools, and materialized views.
Cache frequent or expensive queries (e.g., dashboards, reports) using Redis or similar. Use query fingerprinting to identify reuse patterns.
Maintain consistency with write-through or write-behind strategies. Apply triggers, smart polling, or TTL-based invalidation to keep cache fresh under frequent writes.
Distributed/
multi-tiered caching
Know benefits of shared, distributed cache across nodes.
Use Redis Cluster or Hazelcast. Cache API responses shared across instances.
Orchestrate cache layers (client → edge → app → DB). Implement cache federation and tiered fallback strategies.

Use the comparison table to distinguish foundational cache knowledge from applied and advanced practices, including TTLs, LRU, cache-aside, write-through, service workers, and CDN controls. section 6.4

How Acing the Frontend Interview covers it

How deep it goes
Explains cache layers and trade-offs, then points toward TTLs, eviction, invalidation, and distributed-cache concerns without deeply implementing database internals.
Examples
Uses browser and CDN assets, API responses, sessions, product listings, computed thumbnails, Redis, Memcached, TTLs, and LRU eviction.
What it assumes
Assumes frontend experience while extending reasoning toward backend services, databases, APIs, and distributed-system performance.
What you can do after
Evaluate caching designs by selecting a layer and articulating performance, consistency, expiration, invalidation, and scalability trade-offs.
How it connects
Connects caching with latency, scalability, consistency, invalidation, load balancing, distributed systems, and database load.

Also explained in

Compare how 49 books explain caching →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Frontend Interview. The section links point to the parts of the book it draws on.