Skip to content

OPcache file cache

The OPcache file cache is an optional addition to OPcache. OPcache normally keeps PHP’s compiled code in memory. With the file cache, it also writes that code to a folder on the disk, so it can load it from there instead of compiling the files again.

The file cache helps in the moments when the memory cache is empty or full: right after PHP restarts, or when the memory set aside for OPcache isn’t enough for all files. On hosting where PHP restarts often, it saves the first requests from compiling everything again.

It’s optional. OPcache works fully without it, and most servers don’t use it. On some setups, the file cache is the only cache because shared memory isn’t available. It has nothing to do with a page cache; it stores compiled PHP code, not pages.

Server: The hosting provider decides whether to use it and in which folder. The folder has to exist and be writable for PHP. Reading from disk is slower than from memory, so the speed of the storage matters.

WordPress: Every PHP file that WordPress, the theme and the plugins load ends up in the file cache, so the number of plugins decides how much it holds.

Permo doesn’t show whether the file cache is in use. The OPcache card in System info, tab Server & System, shows whether OPcache runs and how full its memory is; see OPcache.

Sources