Glossary

Cache

A cache is a small, fast store that keeps copies of data likely to be needed again, so the next request avoids a slower trip to the original source.

What is a cache?

Any fast storage placed in front of slower storage to hold recently or frequently used data. The idea repeats at every layer of a computer. CPU caches hide the slowness of RAM. RAM caches hide the slowness of disks. Application caches hide the cost of database queries and page rendering. HTTP caches hide the distance to the origin server. Each layer works the same way: check the fast copy first (a hit), and fall back to the slow source only when needed (a miss).

What are the layers of caching on a server?

LayerTypical sizeAccess timeManaged by
CPU L1 / L2Tens of KB to a few MB per coreAbout 1 to 5 nsHardware
CPU L3Tens to hundreds of MB per chipAbout 10 to 20 nsHardware
RAM page cacheAll free memoryAbout 100 nsLinux kernel
Database buffer poolConfigured share of RAMSub-microsecondMySQL, PostgreSQL
Application and object cacheMB to many GBMicrosecondsOPcache, Redis, Memcached
HTTP cacheGB on RAM or NVMeMicroseconds plus networknginx, Varnish, CDNs

The memory hierarchy explains the hardware side of this ladder in more depth.

Where did all the free RAM go?

Because the page cache uses it. Linux keeps recently read file data in otherwise unused RAM, so the second read of a file comes from memory. That memory is handed back instantly when programs need it. The number to watch is available, not free:

free -h
grep -E '^(Cached|Buffers|MemAvailable)' /proc/meminfo

A server with plenty of available memory and high cache use is healthy. This is also why extra RAM speeds up file servers and databases even when no program asks for it directly. Check memory usage walks through the output.

How do CPU caches affect performance?

Code and data that fit in L1 and L2 run at full speed; every miss to RAM costs hundreds of cycles. Large L3 caches help databases, game servers and virtual machines that jump around in memory. CPU families differ widely here: the EPYC 4005 chips in S13 and S14 and the Xeon 6 chips in our Xeon 6 line line carry large L3 caches. Check yours with lscpu | grep -i cache. Software can help too: compact data structures and processing data in order make better use of whatever cache the CPU has.

Which application caches should a web server use?

  • Bytecode cache: PHP OPcache keeps compiled scripts in memory. Turn it on everywhere; it often doubles PHP throughput on its own.
  • Object cache: Redis or Memcached holds query results, sessions and computed fragments; In-memory caches and stores covers sizing.
  • Full-page cache: nginx fastcgi_cache or proxy_cache stores rendered pages for anonymous visitors, turning a 100 ms page into a sub-millisecond one.
  • Browser cache: long Cache-Control lifetimes on versioned static files keep repeat visitors from downloading them again, which also saves outgoing traffic.

What makes caching hard?

Invalidation: knowing when a cached copy is out of date. Short lifetimes are simple but cache less; long lifetimes need a way to purge or version entries when data changes. The other trap is caching personal data and serving it to the wrong user, so exclude logged-in sessions and anything with cookies from shared caches unless you know exactly what you are doing. Measure the hit ratio at each layer: redis-cli info stats shows keyspace hits and misses, and nginx can log $upstream_cache_status.

How does cache shape hardware choices?

When a workload's hot data fits in RAM, it runs at memory speed; when it spills over, it runs at disk speed. That makes RAM the most effective upgrade for many databases and caches. Our High memory line line goes from 512 GB DDR4 on M1 to 1 TB DDR5 on M13. A dedicated Cache server takes the idea further by putting a whole machine in front of the slow source.

Machines With Large Caches and RAM

ServerProcessorCores / threadsMemoryStorageNetworkPer monthSmallest order
S5Intel Xeon E-2276G6 / 12128 GB DDR42x 1 TB NVMe2x 10 Gbps$88.72$88.72 (1 month)
S13AMD EPYC 4345P8 / 16128 GB DDR52x 2 TB NVMe2x 25 Gbps$237.92$237.92 (1 month)
S14AMD EPYC 4565P16 / 32192 GB DDR52x 4 TB NVMe2x 25 Gbps$317.89$317.89 (1 month)
M12x Intel Xeon Gold 5315Y16 / 32512 GB DDR42x 4 TB NVMe2x 25 Gbps$414.70$414.70 (1 month)
M132x Intel Xeon Gold 5418Y48 / 961 TB DDR52x 4 TB NVMe2x 25 Gbps$849.12$849.12 (1 month)

Keep Reading

Cache server

A server that keeps copies of frequently requested data close to users or apps so the slow origin is asked less often.

Open

The memory hierarchy

From registers through L1, L2 and L3 caches to RAM, NVMe and the network: how each level trades speed for size, and why it shapes performance.

Open

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.

Open

Check memory usage

Read free, /proc/meminfo, vmstat and per-process numbers correctly, and tell real memory pressure apart from a healthy page cache.

Open

FAQ

Quick Answers

A request answered from the cache. A miss is one that has to go to the slower original source.

Linux uses free RAM as page cache for files. Check the available column in free -h, which counts memory that can be reclaimed.

They are CPU caches of growing size and latency. L1 and L2 are per core, L3 is shared across the chip.

Yes. It stores compiled scripts in memory and is one of the cheapest speedups for any PHP site.

When the working data does not fit in memory, yes. More of it stays in the page cache or database buffers instead of on disk.