Set PHP realpath_cache_size 'correctly'

Originally published at: Set PHP realpath_cache_size 'correctly'

In 2012, I started enabling PHP realpath_cache_size and realpath_cache_ttl for performance benefits. At the time, I followed the settings I found here (has since been deleted). It bugged me that I was blindly setting the cache size without knowing how much storage was actually being used. In this post, I will demonstrate how to view the…

1 Like

I’ve never even heard of this setting. Does this only apply to Apache servers?

I currently am running a Litespeed server and an nginx server with PHP-FPM, wondering if this is something I should/can change.

It applies to PHP. See here

Thanks for this.

I had to clear the open_basedir in my control panel (runcloud) in order to get this function to work.

I also notice that the value varies widely, depending on where I dump the variable. On a blank page, like in the code you shared, it tends to be small. When injected into a template within BuddyPress, it ranges from 30-100KB. So, I suppose I could trim the cache size from 4MB to 1MB as you did. But, it seems to me that that’s pretty inconsequential on most servers these days so won’t even bother.

The real question is with regards to open_basedir - whether it should be on or off, and whether the realpath_cache actually makes a meaningful performance difference…

1 Like

Good points. Realpath cache reduces disk lookups. So really, with storage speeds vastly improving over the years… NMVe/SSDs it’s probably not as big of gains as it was back in 2012 when I originally published this article.

Welcome to the forums. :handshake: