Last updated on

Opcode caching is a performance optimization technique that helps your website run faster by storing the “prepared” version of your PHP code in memory. In this guide we’ll learn exactly how Opcode Caching works and how to leverage the pro feature to enhance WordPress performance with W3 Total Cache. 

How Opcode Caching Works

What Happens Normally:

  • PHP Code Execution: WordPress is built with PHP, which is a programming language. Normally, when someone visits your WordPress site, the server reads your PHP code line by line, compiles it (turns it into a format the server can understand called bytecode), and then runs it to generate the web pages.
  • Recompilation: Without opcode caching, every time someone visits your site, the server repeats this process—reads, compiles, and executes the PHP code. This can slow things down, especially if many people are visiting at once because the server is doing the same work repeatedly.

How Opcode Caching Helps:

  • Precompilation: Opcode caching takes the PHP code, compiles it into bytecode once, and stores this compiled version in the server’s memory.
  • Reusing Compiled Code: When the same PHP script is requested again (for example, when another visitor comes to your site), the server doesn’t need to recompile it. Instead, it just uses the already compiled bytecode from memory, skipping the repetitive steps.
  • Speed Boost: Since the server can skip the time-consuming compilation step, it can serve pages much faster. This means your WordPress site loads quicker, which is great for user experience and can even improve your SEO rankings.

How Opcode Caching Specifically Enhances WordPress Performance:

  • Reduced Server Load: WordPress relies heavily on PHP, so opcode caching can significantly reduce the workload on your server.
  • Faster Page Loads: By using cached bytecode, the server delivers pages faster because it’s not wasting time recompiling the same code over and over.
  • Better Performance During High Traffic: Opcode caching is particularly beneficial when your site experiences high traffic because it allows the server to handle more requests efficiently.

Using Opcode Caching with W3 Total Cache

 It is always a good idea to have Opcode Caching enabled as this functionality cannot be disabled, though when enabled it will report the actual state and (in the Pro version) statistics.

In production environments, you may have slightly better performance by disabling the “Validate timestamps” option under General Settings > Opcode Cache. If you are using PHP-FPM, you may not be able to disable this in W3 Total Cache.

When this option is disabled, files will not be recompiled on PHP file updates, such as when the file modification time changes, and will only be recompiled on PHP restart.

Speed Up Your WordPress Website.

A Difference of Just 100ms in Page Load Speeds Can Cause a Visitor to Prefer Your Competitor’s Website.

Choosing a Method

PHP 5.5.0 or later comes with Zend Opcache, which is considered to have deprecated alternatives such as APC / APCu due to its much better performance. Because Zend Opcache is included with modern versions of PHP, it is already present and active, meaning that enabling Opcode Caching with Zend Opcache as the selected method will enable tracking and reporting statistics

Zend Opcache is the Opcode caching implementation included with PHP 5.5.0 and later. Its performance is generally considered to be much faster and more efficient than APC-based Opcode caching.

Alternative PHP Cache (APC)

APC refers to Alternative PHP Cache which provides in-memory Opcode caching and a key-value store for looking up cached items. This is largely deprecated in favor of modern Opcode Caching mechanisms, as APC is not supported in the PHP 7.x branch.

APC is not stable when a lot of memory allocated. In cases where you are caching a small amount of data, APC may be the ideal method for single-instance hosting platforms such as VPS or Dedicated hosting.

Caveats

APC allows a userland-shared memory cache which may be ideal for multi-tenant scenarios, though this functionality is also available in APCu which is compatible with the PHP 7.x release branch.

W3 Total Cache

You haven't seen fast until you've tried PRO

   Full Site CDN + Additional Caching Options
   Advanced Caching Statistics, Purge Logs and More

Everything you need to scale your WordPress Website and improve your PageSpeed.

2 thoughts on “Choosing an Opcode Caching Method with W3 Total Cache

  1. Hi, the Opcode Cache dropdown says unavailable and will not allow me to select Zend Opcache.

    Not sure what to do here. Could you explain please

    thank you

Leave a Reply

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

W3 Total Cache logo

We Can Help Optimize Your Website

Optimize your site’s performance with our one-time premium services or ongoing monthly VIP support. View services

Got a Minute?

Your feedback helps us improve. Complete our customer survey now.

Partners

Bunny CDN Logo