You can speed up your WordPress site so it’s around three times faster or more with the OPcache PHP OPcode caching system.

OPcache is a type of caching system that saves precompiled script bytecode in a server’s memory called a cache, so each time a user visits a web page, it loads faster.

Here’s more detail on OPcache and how to install it for your WordPress site to speed it up.

What is Caching?

Caching is a system you can put in place to speed up your site. It works by saving content to your server’s memory the first time it’s loaded on a web page. Each subsequent page load has the stored content retrieved from memory and served on the page.

This process means cached content is displayed a lot faster than if it’s loaded directly from the server.

It’s like memorizing your multiplication tables. Once you have memorized it, it’s so much faster to recite the answer to a multiplication problem from memory rather than trying to calculate the answer all over again.

A cache works in a similar way. Content is stored in a server’s memory so it can be loaded from there quickly instead of going all the way to the server to load the content which takes more time.

The result being a faster loading WordPress website.

There are also different types of caching such as browser, site, object, and OPcode caching. It’s recommended that you  implement more than one kind to increase your site’s performance.

What is OPcache or PHP Opcode Caching?

OPcache is a type of OPcode caching. This kind of caching compiles human-readable PHP code to code your server understands which is called opcode. This occurs when the PHP file loads on a web page for the first time. Then, it’s saved to the server’s memory for faster loading at each subsequent page visit.

Bytecode cache engines such as OPcache, APC, and Xcache all complete this process the first time the PHP file is executed without having to do it a second, or third time.

How PHP Opcode Caching Works

When a PHP script executes, your server’s cache memory is checked to see if the script has already been cached. If it hasn’t, it’s parsed, which means the code is analyzed.

Then, the script is compiled into opcode making the file readable by the server. Once that’s done, the opcode is saved to the server’s memory.

In other words, it’s stored in your server’s cache. The next time a visitor loads the page with the PHP script, the cached code is executed and loaded much faster.

On the other hand, if the script is loaded on the page and the cache is checked for opcode and finds it, then it’s loaded lickety-split.

How OPcache works
When PHP scripts aren’t in the cache, they’re cached for subsequent page loads.

The Differences Between OPcache and APC Caches

OPcache, APC as well as Xcache are all opcode caching systems. OPcache used to be owned by Zend and Alternative PHP Cache (APC) was a free, open source extension for PHP. Xcache was also an alternative option.

APC was widely used, but it didn’t have the backing that OPcache had so it could be well maintained and stable with each new PHP release.

Fortunately, Zend made OPcache open source and available as an extension since PHP version 5.5. In earlier versions, you have the choice to use APC or OPcache, but if you would like to use the latter, you need to manually install it.

Xcache, on the other hand, is a good alternative to OPcache as a PHP accelerator.

Will OPcache Speed up My WordPress Site?

All three options are suitable for WordPress, but the recommended option for PHP versions 5.5 and above is OPcache. On average, it speeds up WordPress three fold, at the very least for medium to large sites.

If you have a smaller site without many additional PHP scripts or plugins installed, you likely won’t notice much of a difference.

However, you can still install OPcache on even small WordPress sites with no negative effects other than a slight increase in memory usage. But, it won’t be enough to cause any issues. This is similar for medium, large, or enterprise sites.

How to Install OPcache on Your Server

If you have PHP version 5.5 and above, OPcache PHP opcode caching is installed and enabled by default. You don’t have to do anything else. There’s also no additional requirements or configuration needed to run it.

That’s also why you won’t find any options if you were to look for them.

Leave a Reply

Your email address will not be published. Required fields are marked *