What Is Caching?
Caching is the process of storing copies of data in a temporary storage layer so that future requests for that data can be served faster. Instead of generating a response from scratch or fetching it from a distant server every time, a cache delivers a previously stored copy — cutting load times, reducing bandwidth consumption, and lowering the strain on origin infrastructure.
Caching occurs at nearly every layer of the modern web stack, from the visitor's browser all the way back to the origin server. Understanding each layer helps you make informed decisions about performance and content freshness.
Types of Caching
There are four primary caching layers relevant to website operations:
- Browser cache — The visitor's browser stores static assets like images, CSS, JavaScript, and fonts locally. On repeat visits, these assets load from disk instead of being downloaded again. Browser caching is controlled through HTTP response headers sent by your server.
- CDN cache — A content delivery network caches your content at edge servers distributed around the world. When a visitor in London requests your page, the CDN serves it from a nearby edge node rather than routing the request back to your origin server in New York. NOC.org's CDN uses intelligent caching to offload the majority of traffic from your origin.
- DNS cache — DNS resolvers and operating systems cache DNS lookup results so that repeated visits to the same domain do not require a fresh DNS resolution. DNS cache duration is governed by the TTL (time to live) value set on each record.
- Server-side cache — Application-level caches like Varnish, Redis, or Memcached store rendered pages or database query results in memory. This avoids expensive computations or database hits on every request, dramatically improving response times for dynamic sites.
Cache Headers: Cache-Control and Expires
HTTP cache headers tell browsers and intermediate caches how long to store a response and under what conditions to revalidate it:
- Cache-Control — The modern standard for cache directives. Common values include
max-age=3600(cache for one hour),no-cache(always revalidate before using the cached copy),no-store(never cache this response), andpublicorprivate(whether shared caches like CDNs may store the response). - Expires — An older header that specifies an absolute date and time after which the cached copy is considered stale. If both
Cache-ControlandExpiresare present,Cache-Controltakes precedence. - ETag and Last-Modified — These headers enable conditional requests. The browser sends the stored ETag or timestamp back to the server, which responds with
304 Not Modifiedif the content hasn't changed — saving bandwidth without sacrificing freshness.
Cache Invalidation
One of the hardest problems in caching is knowing when to discard stale content. Cache invalidation is the process of removing or refreshing cached data when the underlying content changes. Common approaches include:
- TTL-based expiration — Content is automatically considered stale after a defined time period. Simple but imprecise — content may change before the TTL expires or remain unchanged long after.
- Purge on publish — When content is updated, the application sends a purge request to the CDN or cache layer to immediately remove the old version. The NOC.org CDN supports instant cache purging so updates go live without delay.
- Cache tags — Resources are tagged with identifiers, allowing you to purge all content related to a specific page, category, or asset group in a single operation.
Caching and Performance
Effective caching is one of the highest-impact optimizations available. A well-configured caching strategy can reduce origin server load by 80% to 95%, lower page load times by hundreds of milliseconds, and ensure your site remains responsive during traffic spikes. Combined with a CDN, caching transforms a single-server setup into a globally distributed, high-performance architecture — without requiring changes to your application code.