What is caching, and where can caches be placed in a system?
EasyConceptCaching
Answer
Caching keeps a copy of data in fast storage close to where it is needed, trading memory and some staleness for lower latency and less load on the source. Caches can exist at almost every layer of a request path.
- Client: the browser or mobile app caches responses according to HTTP headers such as
Cache-ControlandETag. - CDN and reverse proxy: edge servers cache static assets and some API responses near users.
- Application: an in-process cache is fastest but separate for each instance; a distributed cache such as Redis or Memcached is shared by all instances.
- Database: buffer pools keep hot pages in memory.
- Measure the hit ratio; a cache that rarely hits only adds complexity and another failure point.