Speeding up localhost response time
I’ve been getting worse and worse response times on localhost when developing WordPress sites locally, using Bitnami. It was getting stupidly slow.
I finally tracked it down to a php.ini setting: realpath_cache_size.
This post shows how to set it correctly. The default value is 16k, but you probably need more.
Basically, you do the following:
- Find php.ini — if you use Bitnami, it will be in a path like /Applications/wordpress-x.x.x-0/php/etc
- Edit it and locate the line with ;realpath_cache_size = 16k
- Remove the ; (semi-colon), which comments out the line, and change 16k to 256k
- Add var_dump(realpath_cache_size()); inside the php of your theme — for example in your theme’s functions.php (I’m assuming you’re using localhost, so getting output on your web page is not a problem for you). This will tell you how much cache you are using.
- Load a complex page and take a note of the figure that’s output — it will display as something like int(36360)
- Edit php.ini again and reduce the realpath_cache_size figure to something that is comfortably above the figure that was output (but don’t make it over-large). For example, if you get int(36360) as output, which would indicate that you need at least 36k, then realpath_cache_size = 64k will probably be fine.