Reputation: 93666
Recent versions of PHP have a cache of filenames for knowing the real path of files, and require_once()
and include_once()
can take advantage of it.
There's a value you can set in your php.ini to set the size of the cache, but I have no idea how to tell what the size should be. The default value is 16k, but I see no way of telling how much of that cache we're using. The docs are vague:
Yes, I can jack up the amount of cache allowed, and run tests with ab
or some other testing, but I'd like something with a little more introspection than just timing from a distance.
Upvotes: 5
Views: 8290
Reputation: 2159
To expand on the answer provided by Noodles, you can create a little test.php with the following code:
<?php
echo "<br>cache size: ".realpath_cache_size();
echo "<br>";
echo "<br>cache: ".print_r(realpath_cache_get(););
?>
Upload this to your site and navigate to it. It will show you the amount of bytes currently being used by your cache, as well as what's actually in the cache. This value is changing all the time so keep hitting that F5 button to get a better sense of where you're at. It's a good idea also to do your testing during peak times.
If you see the value is frequently hitting your max cache size as defined in your php.ini then it's time to increase that value.
Keep in mind that the default PHP setting is 16K which is 16384 bytes.
Upvotes: 1
Reputation: 928
You've probably already found this, but for those who come across this question, you can use realpath_cache_size() and realpath_cache_get() to figure out how much of the realpath cache is being used on your site and tune the settings accordingly.
Upvotes: 4
Reputation:
the 16K is the # of files not activity.
Set to 1k for most sites. Very similar to settings in APC, xcache ea etc.
Upvotes: -3
Reputation: 20592
Though I can't offer anything specific to your situation, my understanding is that 16k is pretty low for most larger PHP applications (particularly ones that use a framework like the Zend Framework). I'd say at least double the cache size if your application uses lots of includes and see where to go from there. You might also want to increase the TTL as long as your directory structure is pretty consistent.
Upvotes: 3