How Useful Is OPcache for WordPress?

Nobody, yes, you heard it right, “NOBODY” likes a slow site. Users don’t even think twice about abandoning a slow site, which ultimately increases your site’s bounce rate. Therefore, webmasters apply different ways to speed up their WordPress sites. You may have heard of many strategies for optimizing sites for loading speed.

Today, in this guide, I will discuss one of them, and it’s none other than OPcache. It is a type of caching system that is used to save precompiled script bytecode in a server’s memory, which is known as a cache.

So, here are more details on how useful is OPcache for WordPress sites to improve speed.

What is OPcache?

What is OPcache

A cache stores content in a server’s memory so that it can load quickly, without going all the way to the server to load the entire page once again while further requested. This way, it reduces the amount of work and the web server’s load and makes WordPress faster.

There are several types of caching, such as Browser caching, object caching, and OPcode caching.

As per, WP Rocket, OPcache is a type of OPcode caching that compiles the human-readable PHP code to code on your server. This means, when the PHP file is executed on a server for the first time, it is compiled into OPcode, a code that is understandable by the machine.

OPcache stores this code into memory on the first execution without doing it a second or third time to improve the performance boost.

How Useful Is OPcache for WordPress?

How Useful Is OPcache for WordPress

If your server manages to handle the incoming traffic with low response times, then you may not need to use OPcache. But, when it comes to managing a site with a lot of traffic, every single optimization step will count.

OPcache is suitable for WordPress, but for PHP versions 5.5 and above is OPcache. It is also quite easy to install and configure, and you won’t need much time to set it up. Now, to understand how useful is OPcache for WordPress?, I’ll share a real-time test from AppDynamics.

According to AppDynamics, when they enable OPcache on their application, then they find a reduction in response time by 14%. In fact, the decrease in response times of several actions of a web application varied from 6% to 74%.

On average, it helps to speed up your WordPress at the very least for medium to large sites. If you run a small site without additional PHP scripts or plugins installed, you probably won’t see a much-improved speed difference. But, still, you can use it without any negative impact and a slight increase in memory usage.

Installing OPcache on Your Server

The best thing is, sites with PHP version 5.5 and above don’t need to go through these steps as these versions automatically enable OPCache for servers. These processes are for those who are using PHP version below 5.5. So, here’s how you should install OPcache on your server.

According to the PHP manual, OPcache can be compiled as a shared extension. So, if you disabled the default extensions building with –disable-all, then you must compile PHP with the –enable-opcache option for OPcache to be available.

Once compiled, use the  zend_extension configuration directive to load the OPcache extension into PHP.

You can do this on non-Windows platforms-

zend_extension=/full/path/to/opcache.so

And on Windows-

zend_extension=C:\path\to\php_opcache.dll 

Once you’ve done the above steps, restart PHP using SSH. To restart PHP on Apache, enter the following command by GitHub.

apache2ctl restart

For Nginx,

service nginx restart

To install OPcache on earlier versions like below 5.5, you should manually install OPcache using the PECL command below-

pecl install zendopcache-beta

Then, go for php.ini file-

pecl config-get php_ini

Lastly, update the php.ini file with the following recommended commands-

opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

To find the php.ini file, navigate to your site’s file folder system. Still, if you find it difficult to discover the php.ini file, contact your hosting provider.

Conclusion

Many site owners already have the latest version of PHP installed on their server. This means they don’t need to enable OPcache as it already has OPcache enabled automatically.

Site those that have PHP version below than 5.5, you should install OPcache manually. Don’t worry! You can do this easily with the above-outlined steps from this guide. Here, I’ve shared how useful is OPcache for WordPress, along with the installation processes. Hopefully, this guide will help you in this process.

If you have other questions or comments regarding the subject, let me know in the comment section below. Also, you can share your thoughts about this guide; I’d love to hear from you all.

Leave a Comment