What is a cache server?
It is a machine whose main job is remembering answers. The first time someone asks for a page, an image or the result of a query, the cache forwards the request to the source, called the origin, keeps a copy of the response and returns it. The next request for the same thing is answered from the copy in microseconds or milliseconds instead of running the full work again. A good cache absorbs most of the traffic, which lets a modest origin serve far more users.
What kinds of cache server exist?
| Kind | Stores | Common software | Main resource |
|---|---|---|---|
| HTTP reverse proxy cache | Whole responses: pages, images, video segments | nginx proxy_cache, Varnish | Disk and port speed |
| In-memory data cache | Objects, sessions, query results | Redis, Valkey, Memcached | RAM |
| Package or artifact cache | Downloads for build systems and servers | apt-cacher-ng, registry mirrors | Disk |
| DNS cache | Name lookups | Unbound | Tiny |
The in-memory kind is covered in detail on In-memory caches and stores.
What is a hit ratio and why does it matter?
The hit ratio is the share of requests answered from the cache. At 90 percent, the origin sees one request in ten; at 99 percent, one in a hundred. Small changes near the top make a large difference to the origin's load, so most cache tuning is about raising the hit ratio: caching more types of response, keeping objects longer, normalizing URLs so the same content is not stored under many keys, and giving the cache enough memory or disk to hold the popular set. nginx can report it per request with $upstream_cache_status in the access log.
How long should things stay cached?
Each object gets a time to live (TTL). Static files with versioned names can stay for a year. HTML for logged-out visitors might be cached for a minute, which already cuts load enormously at busy times. Personalized pages and anything after login should usually not be cached at the HTTP layer at all. When content changes before its TTL runs out, you invalidate it: purge the key, or include a version in the URL so the new copy has a new key. Stale-while-revalidate settings let the cache serve a slightly old copy while it fetches a fresh one, which hides origin slowness from visitors.
What hardware suits a cache server?
An in-memory cache is all about RAM; CPU barely matters unless request rates are extreme, and Redis uses one main thread per instance anyway. A disk cache for files wants fast NVMe and, above all, network capacity, because its whole purpose is sending data out.
- Session and object cache for a few apps: S5 with 128 GB DDR4.
- Large shared data cache: M1 with 512 GB DDR4, or M13 with 1 TB DDR5 at the top end.
- HTTP cache for downloads or video: S13 with a 2x 25 Gbps connection and NVMe storage.
Where should a cache server sit?
Close to whoever asks. An application cache belongs in the same city as the app, so every lookup is a sub-millisecond hop. An HTTP cache for visitors belongs near the visitors. With identical models in Phoenix, Ashburn, Chicago, Seattle, Amsterdam and Singapore, you can keep one origin and add caches where your audience is, such as Amsterdam for Europe and Singapore for Asia. Every cache in another city fetches content from the origin over the public internet, which counts as outgoing traffic on the origin, and then serves it many times, which counts on the cache.
Cache server or bigger origin?
If the same responses are requested again and again, a cache is cheaper than scaling the origin, because serving a stored copy costs almost nothing. If every response is unique, as with search results for rare queries or personalized dashboards, a cache helps little and the origin needs the capacity. Measure first: log how often the same URLs or keys repeat over an hour, and the answer is usually clear.
Related ideas: a Proxy server is the broader term that includes caching proxies, and Latency explains why distance to the cache matters.
Machines Built Around Memory and Bandwidth
| Server | Processor | Cores / threads | Memory | Storage | Network | Per month | Smallest order |
|---|---|---|---|---|---|---|---|
| S5 | Intel Xeon E-2276G | 6 / 12 | 128 GB DDR4 | 2x 1 TB NVMe | 2x 10 Gbps | $88.72 | $88.72 (1 month) |
| S13 | AMD EPYC 4345P | 8 / 16 | 128 GB DDR5 | 2x 2 TB NVMe | 2x 25 Gbps | $237.92 | $237.92 (1 month) |
| M1 | 2x Intel Xeon Gold 5315Y | 16 / 32 | 512 GB DDR4 | 2x 4 TB NVMe | 2x 25 Gbps | $414.70 | $414.70 (1 month) |
| M6 | 2x Intel Xeon Gold 6258R | 56 / 112 | 768 GB DDR4 | 2x 2 TB NVMe | 2x 25 Gbps | $664.12 | $664.12 (1 month) |
| M13 | 2x Intel Xeon Gold 5418Y | 48 / 96 | 1 TB DDR5 | 2x 4 TB NVMe | 2x 25 Gbps | $849.12 | $849.12 (1 month) |
Keep Reading
In-memory caches and stores
Redis, Valkey or Memcached on machines with 128 GB to 1 TB of RAM, sized with snapshot headroom and NUMA in mind.
OpenProxy server
A server that sits between clients and destinations and forwards their traffic, in forward or reverse form, for control, caching or privacy.
OpenLatency
Why distance sets the floor for ping time, how to estimate round trips between our six cities and how to choose a location.
OpenIn-memory databases
How databases that live in RAM work, how they survive restarts, which engines to consider and how to size the machine with fork headroom.
OpenFAQ
Quick Answers
A CDN is a network of many cache servers in many places. A single cache server is one of those building blocks, run by you.
Redis is often used as one, storing objects and sessions in memory. It can also act as a database, queue or message broker.
It evicts entries according to a policy, usually least recently used, to make room for new ones.
Generally not at the HTTP layer. Cache the data behind them in an object cache instead.
RAM for in-memory caches, and port speed plus fast disks for HTTP and file caches.