Rabin R
System Designadvanced

The layers of caching in a frontend system

From HTTP cache headers to service workers to in-memory signals — where each layer belongs.

Introduction

Caching is not one decision but a stack of them, each with a different invalidation story.

  • CDN / edge: immutable, content-hashed assets, cache forever.
  • HTTP cache: ETags and max-age for API responses that tolerate staleness.
  • Service worker: offline shell and stale-while-revalidate for data.
  • In-memory (signals/resource): dedupe within a session, cleared on reload.