Skip to main content

Caching

PropertyValue
descriptionStoring reusable data closer to where it is needed so future requests can be served faster and with less work.
tagsref

Caching is the practice of storing reusable data closer to where it is needed so future requests can be served faster and with less work.

Caching is used across browsers, servers, databases, APIs, CDNs, and applications to improve performance and reduce repeated computation or retrieval.

What it does

Caching improves speed and efficiency by reusing previously fetched or computed results.

It is commonly used to:

  • Speed up website and app responses
  • Reduce repeated database or API work
  • Lower server load
  • Improve perceived performance in browsers and apps
  • Reduce bandwidth and infrastructure costs

Core concepts

Reuse instead of recompute

A cache stores a result so it can be reused later.

That result might be page output, API data, database query results, assets, or computed values.

Freshness and invalidation

Caching is useful only while the cached data is still valid enough for the use case.

That is why cache invalidation and expiry rules are central to good caching design.

Many layers

Caching can happen at multiple layers at once.

Common layers include the browser, application, server, database, and edge or CDN layer.

Common use cases

  • Browser asset caching
  • Full-page website caching
  • API response caching
  • Database query caching
  • Object and fragment caching in applications

Practical notes

  • Caching improves performance, but it also adds complexity around staleness and invalidation.
  • The most important question is often not "can this be cached?" but "for how long and under what rules?"
  • In web systems, caching often depends on HTTP headers, application logic, and infrastructure behavior together.
  • Good caching strategy can improve both user experience and operational efficiency significantly.

Sources Used

Frequently Asked Questions

Is caching always good?

No. It is beneficial when the cached result stays valid long enough to be reused safely. Poorly designed caching can serve stale or incorrect data.

Is browser caching the same as server caching?

No. They are different layers with different rules and responsibilities.

Why is cache invalidation important?

Because stale cached data can become incorrect even if it is fast.