CDNs and Caching

CDNs and Caching

Two techniques do most of the heavy lifting in web performance: serving content from close to the user, and avoiding repeated work by reusing results. The first is what a CDN provides; the second is caching. They are distinct ideas that work best together.

What a CDN does

A content delivery network (CDN) is a geographically distributed set of edge servers that hold copies of a site’s assets — images, stylesheets, scripts, and often full pages — in many locations around the world. When a visitor requests the site, the CDN serves those assets from the edge server nearest them rather than from the single origin server where the site actually lives.

This produces two benefits:

  • Lower latency. Data travels a shorter physical distance, so content arrives faster. A visitor on another continent no longer waits on a round trip to a distant origin.
  • Reduced origin load. Because the edge handles most requests, the origin server serves far less traffic, freeing it to handle the dynamic work only it can do — and helping the site stay up during traffic spikes.

Many CDNs also bundle security features such as DDoS mitigation and a web application firewall, covered in SSL and Website Security.

Caching layers

Caching means storing the result of expensive work so it can be reused instead of recomputed. On a website it happens at several layers:

  • Page (full-page) caching — stores the complete rendered HTML of a page so repeat requests skip the whole build process. The biggest single win for content that does not change per visitor.
  • Object caching — stores the results of database queries and other expensive operations in memory, so the application avoids re-querying for the same data.
  • Opcode caching — keeps compiled application code in memory so the server does not re-parse source files on every request.
  • Browser caching — instructs the visitor’s browser to store static assets locally, so on return visits those files load from the device instead of the network.

Each layer removes work at a different point, and a well-tuned site uses several at once.

Static vs. dynamic, and invalidation

Caching is easiest for static content — assets that look the same for everyone. Dynamic content, such as a logged-in account page or a live cart, must be handled carefully so users never see someone else’s cached data.

The tension in every cache is freshness. A TTL (time to live) sets how long a cached copy is considered valid, and cache invalidation clears or refreshes copies when the underlying content changes — for example, purging the cache after publishing an update so visitors see the new version rather than a stale one.

Relationship to performance

Caching and CDNs are among the highest-leverage performance tools available. By cutting the time to first byte and speeding asset delivery, they directly improve loading metrics — notably Largest Contentful Paint — and support strong Core Web Vitals. By absorbing traffic at the edge and skipping repeated computation, they also keep sites stable and responsive under load that would otherwise overwhelm the origin.

They are not a substitute for an efficient site: caching a slow, bloated page makes it load faster but does not fix the underlying weight. Used alongside lean assets and good hosting, though, they turn an adequately fast site into a genuinely quick one.

For how these gains register as ranking and experience signals, see Core Web Vitals; for the safety and identity layer CDNs often include, see SSL and Website Security.

This entry was posted in . Bookmark the permalink.