If you’ve done anything with optimizing the speed of websites, you know that caching is a must. It basically means you’re creating a page once, and then using it multiple times—as opposed to having to create it every time someone asks for it.
So caching is good, is what I’m saying.
There’s a caching superpower that you can employ that most people aren’t aware of: caching to memory instead of to disk.
Whether you’re using a caching plugin, or doing opcode caching, or using fast-cgi caching (or all three), you should be writing your cache files to a directory that lives in tempfs.
tempfs is a filesystem in memory. Most modern Linux distros have it on by default, actually:
- In CentOS your default tempfs directory is
- In Ubuntu your default tempfs directory is
So, whatever you’re using to create cache files, make use of your Linux distro’s built-in memory-based file system.