The PHP directive
realpath_cache_size sets the size of the realpath cache to be used by PHP. Increasing
realpath_cache_size might greatly improve PHP performance, as PHP states: “
this value should be increased on systems where PHP opens many files.” Setting a correct value for PHP realpath_cache_size can greatly improve PHP performance and optimize WordPress – and other CMS’s – websites.
All kudos for this goes to Hayden James, who posted this back in november 2011.
The other day I was looking to even further optimize PHP performance on our Windows Server IIS web servers. While going through my
php.ini file, I couldn’t find a setting in need of optimization. Even
realpath_cache_size was increased to 128k (defaults to 16k), but somehow it caught my eye.
While doing a normal Google search, I stumbled upon the earlier mentioned blog post by Hayden James, and that made me testing with the following:
dump realpath_cache_size result
<?php var_dump( realpath_cache_size() ); ?>
This will dump the
realpath_cache_size() usage, e.g how many kB’s are currently in use.
dump realpath_cache_get result – e.g the cached files and locations:
<?php var_dump( realpath_cache_get() ); ?>
This dumps the cached files and locations.
However, Magento requires
realpath_cache_size to be set much higher, and Prestashop does too.
For Magento and PrestaShop, set its value around 130 – 150 kB, because they open lots of files. This made me increase the value for PHP’s
realpath_cache_size setting to tune PHP performance of Magento- and Prestashop webshops on Windows Server IIS web servers.
The realpath_cache_size size represents the total number of bytes in the path strings stored, plus the size of the data associated with the cache entry. This means that in order to store longer paths in the cache, the cache size must be larger. This value does not directly control the number of distinct paths that can be cached.