NODEJS Contents

Caching Basics for APIs (Where It Fits)

Caching reduces latency and cost; apply it deliberately at HTTP, application, or data layers.

On this page

HTTP Caching Basics

HTTP caching uses headers like Cache-Control and ETag to avoid unnecessary requests.

Example

Cache-Control: public, max-age=60
ETag: "abc123"

Layered Strategy

  • CDN caching for public resources
  • In-memory caching for expensive computations
  • Database-level caching for heavy queries

Production Risk

Improper invalidation leads to stale data. Always define clear cache invalidation rules before enabling aggressive caching.