{"id":3722,"date":"2025-12-30T13:19:10","date_gmt":"2025-12-30T10:19:10","guid":{"rendered":"https:\/\/www.dchost.com\/blog\/php-opcache-settings-best-configuration-for-wordpress-laravel-and-woocommerce\/"},"modified":"2026-11-04T22:24:13","modified_gmt":"2026-11-04T19:24:13","slug":"php-opcache-settings-wordpress-laravel-woocommerce","status":"publish","type":"post","link":"https:\/\/www.dchost.com\/blog\/en\/php-opcache-settings-wordpress-laravel-woocommerce\/","title":{"rendered":"PHP OPcache Settings for WordPress, Laravel and WooCommerce"},"content":{"rendered":"<div class=\"dchost-blog-content-wrapper\"><p>PHP OPcache can reduce repeated compilation work for WordPress, Laravel and WooCommerce. It is worth reviewing alongside PHP-FPM and basic PHP limits. The resulting CPU and request-latency improvements depend on the workload. In this guide we will explain OPcache directives for WordPress, Laravel and WooCommerce and provide configuration examples to evaluate against your PHP version and deployment process. Whether you are on shared hosting, an NVMe <a href=\"https:\/\/www.dchost.com\/vps\">VPS<\/a> or a <a href=\"https:\/\/www.dchost.com\/dedicated-server\">dedicated server<\/a>, you will leave with a framework for selecting OPcache settings to match your deployment workflow.<\/p>\n<div id=\"toc_container\" role=\"navigation\" aria-label=\"Table of Contents\" data-nosnippet class=\"toc_transparent no_bullets toc_numbered toc_title_center\"><p class=\"toc_title\">\u0130\u00e7indekiler<\/p><ul class=\"toc_list\"><li><a href=\"#What_PHP_OPcache_Really_Does_for_Your_PHP_Apps\"><span class=\"toc_number toc_depth_1\">1.<\/span> What PHP OPcache Really Does for Your PHP Apps<\/a><\/li><li><a href=\"#OPcache_Baseline_Settings_The_Short_Version\"><span class=\"toc_number toc_depth_1\">2.<\/span> OPcache Baseline Settings: The Short Version<\/a><\/li><li><a href=\"#Understanding_Key_OPcache_Directives_One_by_One\"><span class=\"toc_number toc_depth_1\">3.<\/span> Understanding Key OPcache Directives One by One<\/a><ul><li><a href=\"#opcacheenable_and_opcacheenable_cli\"><span class=\"toc_number toc_depth_2\">3.1.<\/span> opcache.enable and opcache.enable_cli<\/a><\/li><li><a href=\"#opcachememory_consumption\"><span class=\"toc_number toc_depth_2\">3.2.<\/span> opcache.memory_consumption<\/a><\/li><li><a href=\"#opcacheinterned_strings_buffer\"><span class=\"toc_number toc_depth_2\">3.3.<\/span> opcache.interned_strings_buffer<\/a><\/li><li><a href=\"#opcachemax_accelerated_files\"><span class=\"toc_number toc_depth_2\">3.4.<\/span> opcache.max_accelerated_files<\/a><\/li><li><a href=\"#validate_timestamps_and_revalidate_freq\"><span class=\"toc_number toc_depth_2\">3.5.<\/span> validate_timestamps and revalidate_freq<\/a><\/li><li><a href=\"#opcachemax_wasted_percentage\"><span class=\"toc_number toc_depth_2\">3.6.<\/span> opcache.max_wasted_percentage<\/a><\/li><li><a href=\"#opcachesave_comments\"><span class=\"toc_number toc_depth_2\">3.7.<\/span> opcache.save_comments<\/a><\/li><li><a href=\"#opcachefile_update_protection\"><span class=\"toc_number toc_depth_2\">3.8.<\/span> opcache.file_update_protection<\/a><\/li><li><a href=\"#opcacherestrict_api\"><span class=\"toc_number toc_depth_2\">3.9.<\/span> opcache.restrict_api<\/a><\/li><li><a href=\"#JIT_opcachejit_and_opcachejit_buffer_size\"><span class=\"toc_number toc_depth_2\">3.10.<\/span> JIT: opcache.jit and opcache.jit_buffer_size<\/a><\/li><\/ul><\/li><li><a href=\"#Recommended_OPcache_Configurations_by_Stack\"><span class=\"toc_number toc_depth_1\">4.<\/span> Recommended OPcache Configurations by Stack<\/a><ul><li><a href=\"#1_WordPress_WooCommerce_on_Shared_Hosting\"><span class=\"toc_number toc_depth_2\">4.1.<\/span> 1) WordPress &amp; WooCommerce on Shared Hosting<\/a><\/li><li><a href=\"#2_WordPress_WooCommerce_on_a_VPS_or_Dedicated_Server\"><span class=\"toc_number toc_depth_2\">4.2.<\/span> 2) WordPress &amp; WooCommerce on a VPS or Dedicated Server<\/a><\/li><li><a href=\"#3_Laravel_on_a_VPS_or_Dedicated_Server\"><span class=\"toc_number toc_depth_2\">4.3.<\/span> 3) Laravel on a VPS or Dedicated Server<\/a><\/li><\/ul><\/li><li><a href=\"#How_OPcache_Interacts_with_PHPFPM_JIT_and_Application_Caches\"><span class=\"toc_number toc_depth_1\">5.<\/span> How OPcache Interacts with PHP\u2011FPM, JIT and Application Caches<\/a><ul><li><a href=\"#OPcache_and_PHPFPM_Pools\"><span class=\"toc_number toc_depth_2\">5.1.<\/span> OPcache and PHP\u2011FPM Pools<\/a><\/li><li><a href=\"#OPcache_vs_Object_Cache_RedisMemcached\"><span class=\"toc_number toc_depth_2\">5.2.<\/span> OPcache vs Object Cache (Redis\/Memcached)<\/a><\/li><li><a href=\"#OPcache_and_JIT_in_Real_Projects\"><span class=\"toc_number toc_depth_2\">5.3.<\/span> OPcache and JIT in Real Projects<\/a><\/li><\/ul><\/li><li><a href=\"#Monitoring_and_Debugging_OPcache_in_Production\"><span class=\"toc_number toc_depth_1\">6.<\/span> Monitoring and Debugging OPcache in Production<\/a><ul><li><a href=\"#Checking_OPcache_Configuration_and_Status\"><span class=\"toc_number toc_depth_2\">6.1.<\/span> Checking OPcache Configuration and Status<\/a><\/li><li><a href=\"#Common_OPcacheRelated_Issues\"><span class=\"toc_number toc_depth_2\">6.2.<\/span> Common OPcache\u2011Related Issues<\/a><\/li><li><a href=\"#Small_OPcache_Status_Dashboard\"><span class=\"toc_number toc_depth_2\">6.3.<\/span> Small OPcache Status Dashboard<\/a><\/li><\/ul><\/li><li><a href=\"#Safe_Deployment_Workflow_with_OPcache_Enabled\"><span class=\"toc_number toc_depth_1\">7.<\/span> Safe Deployment Workflow with OPcache Enabled<\/a><\/li><li><a href=\"#Putting_It_All_Together_Practical_Checklists\"><span class=\"toc_number toc_depth_1\">8.<\/span> Putting It All Together: Practical Checklists<\/a><ul><li><a href=\"#Checklist_for_WordPress_WooCommerce\"><span class=\"toc_number toc_depth_2\">8.1.<\/span> Checklist for WordPress \/ WooCommerce<\/a><\/li><li><a href=\"#Checklist_for_Laravel\"><span class=\"toc_number toc_depth_2\">8.2.<\/span> Checklist for Laravel<\/a><\/li><\/ul><\/li><li><a href=\"#Final_Thoughts_and_Next_Steps\"><span class=\"toc_number toc_depth_1\">9.<\/span> Final Thoughts and Next Steps<\/a><\/li><\/ul><\/div>\n<h2><span id=\"What_PHP_OPcache_Really_Does_for_Your_PHP_Apps\">What PHP OPcache Really Does for Your PHP Apps<\/span><\/h2>\n<p>Without OPcache, PHP needs to read, parse and compile source code into opcodes for each request. OPcache stores compiled opcodes in memory so later requests can reuse them instead of recompiling. That means:<\/p>\n<ul>\n<li>Less CPU time spent compiling cached PHP files.<\/li>\n<li>Potentially lower request latency; measure the effect under the actual workload.<\/li>\n<li>Potentially more capacity from the same hardware, subject to other bottlenecks.<\/li>\n<\/ul>\n<p>For WordPress and WooCommerce, this mostly accelerates core, plugin and theme PHP files. For Laravel, it speeds up framework classes, your application code and vendor libraries. OPcache is not a replacement for object cache (Redis\/Memcached) or full\u2011page caching, but it is the base layer. Evaluate it alongside the techniques we covered in <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-server-tuning-php-redis-mysql\/\">our server\u2011side optimization guide for WordPress (PHP\u2011FPM, OPcache, Redis and MySQL tuning)<\/a>.<\/p>\n<h2><span id=\"OPcache_Baseline_Settings_The_Short_Version\">OPcache Baseline Settings: The Short Version<\/span><\/h2>\n<p>Before diving deep, here is an illustrative baseline to evaluate on supported PHP 8.3+ versions for WordPress, WooCommerce and Laravel on a typical VPS (2\u20134 vCPU, 4\u20138 GB RAM):<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">; Enable OPcache\nopcache.enable=1\nopcache.enable_cli=0\n\n; Memory and file capacity\nopcache.memory_consumption=256\nopcache.interned_strings_buffer=16\nopcache.max_accelerated_files=20000\nopcache.max_wasted_percentage=5\n\n; File change detection (for shared hosting \/ simple setups)\nopcache.validate_timestamps=1\nopcache.revalidate_freq=60\n\n; Preserve doc comments; leave file-check overrides disabled\nopcache.save_comments=1\nopcache.enable_file_override=0\n\n; JIT (optional, usually OFF for classic WordPress\/WooCommerce)\nopcache.jit=0\nopcache.jit_buffer_size=0\n<\/code><\/pre>\n<p>Prerequisite: OPcache must already be installed and loaded for the PHP SAPI serving the site. Check the existing extension configuration rather than adding a duplicate loader; package names and loader paths vary by deployment.<\/p>\n<p>You will tune these numbers depending on:<\/p>\n<ul>\n<li>PHP version and the directives it supports<\/li>\n<li>Project size (number of PHP files, plugins, Composer packages)<\/li>\n<li>Server RAM<\/li>\n<li>Deployment workflow (manual FTP vs automated CI\/CD)<\/li>\n<\/ul>\n<p>Next, we will go directive by directive and then build tailored configs for WordPress, Laravel and WooCommerce. After configuration changes, use deployment tooling for a controlled reload of the actual PHP\u2011FPM master serving the site, or the corresponding web SAPI. An FPM reload affects all workers under that master, not just one pool.<\/p>\n<h2><span id=\"Understanding_Key_OPcache_Directives_One_by_One\">Understanding Key OPcache Directives One by One<\/span><\/h2>\n<h3><span id=\"opcacheenable_and_opcacheenable_cli\">opcache.enable and opcache.enable_cli<\/span><\/h3>\n<p><strong>opcache.enable<\/strong> turns OPcache on for web SAPI (PHP\u2011FPM, mod_php, etc.). This should almost always be <strong>1<\/strong> on production servers.<\/p>\n<p><strong>opcache.enable_cli<\/strong> controls OPcache for command-line PHP. With file caching disabled, ordinary separately launched CLI commands do not share a warm in-memory cache across invocations. A long-running process may reuse compiled scripts, but gains depend on repeated compilation and workload, not duration alone.<\/p>\n<ul>\n<li><strong>Shared hosting \/ small VPS:<\/strong> <code>opcache.enable_cli=0<\/code><\/li>\n<li><strong>Long-running CLI workloads:<\/strong> evaluate <code>opcache.enable_cli=1<\/code> against measured compilation work<\/li>\n<\/ul>\n<h3><span id=\"opcachememory_consumption\">opcache.memory_consumption<\/span><\/h3>\n<p>This sets how much shared memory (in MB) OPcache can use to store compiled PHP code. If shared memory is exhausted, new cache misses may run uncached or use a separately configured file cache. OPcache does not evict old scripts to make room; exhaustion can schedule a restart subject to the wasted-memory threshold. Monitor memory usage, misses and restart counts before resizing.<\/p>\n<ul>\n<li><strong>Small WordPress sites (few plugins):<\/strong> 64\u2013128 MB<\/li>\n<li><strong>WooCommerce \/ multiple plugins:<\/strong> 192\u2013256 MB<\/li>\n<li><strong>Medium Laravel apps with many Composer deps:<\/strong> 256\u2013512 MB<\/li>\n<li><strong>Very large multi\u2011tenant or monorepo apps:<\/strong> 512 MB+<\/li>\n<\/ul>\n<p>On a server with 4\u20138 GB RAM, allocating 256 MB to OPcache is a starting point to evaluate alongside the memory needed by PHP\u2011FPM, the database and other services. Review memory usage alongside hit rate and deployment-related changes before deciding whether to increase the allocation.<\/p>\n<h3><span id=\"opcacheinterned_strings_buffer\">opcache.interned_strings_buffer<\/span><\/h3>\n<p>PHP can &#8220;intern&#8221; strings \u2013 store a single copy in memory and reuse it \u2013 which reduces memory usage and speeds comparisons. <strong>opcache.interned_strings_buffer<\/strong> controls how many megabytes are available for those interned strings.<\/p>\n<ul>\n<li><strong>Do not assume the default is insufficient<\/strong>; assess observed buffer usage.<\/li>\n<li>For modern frameworks and plugin\u2011heavy WordPress, <strong>16\u201332 MB<\/strong> is a range to evaluate if the current buffer is insufficient.<\/li>\n<\/ul>\n<p>An example starting value:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">opcache.interned_strings_buffer=16<\/code><\/pre>\n<p>Consider 32 MB if observed buffer usage warrants a larger allocation.<\/p>\n<h3><span id=\"opcachemax_accelerated_files\">opcache.max_accelerated_files<\/span><\/h3>\n<p>This sets the maximum key capacity of OPcache&#8217;s script hash table. The effective capacity is rounded up to the first supported prime at least as large as the configured value: for example, 20000 becomes 32531. Monitor key usage as well as cached script count. If the table fills, new scripts cannot enter shared memory; misses may run uncached or use the configured file cache, and a restart may be scheduled conditionally rather than dropping older entries.<\/p>\n<p>Illustrative starting values; verify the required key capacity in the actual application:<\/p>\n<ul>\n<li><strong>Small WordPress sites:<\/strong> 8000\u201310000<\/li>\n<li><strong>WooCommerce + many plugins:<\/strong> 20000<\/li>\n<li><strong>Medium\u2013large Laravel apps:<\/strong> 20000\u201340000<\/li>\n<\/ul>\n<p>Choose capacity based on the PHP files the application uses, leaving room for growth rather than raising the limit solely because the hardware is newer.<\/p>\n<h3><span id=\"validate_timestamps_and_revalidate_freq\">validate_timestamps and revalidate_freq<\/span><\/h3>\n<p>These two settings control how OPcache notices file changes:<\/p>\n<ul>\n<li><strong>opcache.validate_timestamps<\/strong> \u2013 1 enables periodic timestamp validation on requests; 0 disables it, so changed code requires an explicit cache refresh. Compile-time timestamp checks can still occur when <code>opcache.file_update_protection<\/code> or <code>opcache.max_file_size<\/code> is nonzero.<\/li>\n<li><strong>opcache.revalidate_freq<\/strong> \u2013 the interval in seconds when validation is enabled; 0 checks on every request. It is ignored when validation is disabled. This is request-driven checking, not a wall-clock deployment guarantee.<\/li>\n<\/ul>\n<p>On shared hosting or any environment where files can change at random times (manual FTP, plugin uploads via dashboard), you should keep <strong>opcache.validate_timestamps=1<\/strong>.<\/p>\n<p>Patterns to evaluate: intervals of 30\u201360 seconds trade fewer timestamp checks for delayed change detection, so updates may not become visible immediately.<\/p>\n<ul>\n<li><strong>Shared hosting WordPress:<\/strong> <code>opcache.validate_timestamps=1<\/code>, <code>opcache.revalidate_freq=60<\/code><\/li>\n<li><strong>VPS with simple manual deploys:<\/strong> <code>opcache.validate_timestamps=1<\/code>, with an illustrative <code>opcache.revalidate_freq=30<\/code><\/li>\n<li><strong>CI\/CD with atomic releases:<\/strong> consider <code>opcache.validate_timestamps=0<\/code> only with a verified cache-refresh workflow on every deployment and rollback. Run <code>opcache_reset()<\/code> in a restricted context sharing the site&#8217;s serving cache, or perform a controlled reload of the actual serving PHP\u2011FPM master. An ordinary standalone CLI reset does not clear the web cache. Reset affects subsequent script loads, not already executing code or the separate file cache.<\/li>\n<\/ul>\n<p>If you are moving towards zero\u2011downtime deployments, the patterns in our guides on <a href=\"https:\/\/www.dchost.com\/blog\/en\/zero-downtime-ci-cd-to-a-vps-the-friendly-rsync-symlink-systemd-playbook-i-keep-reusing\/\">zero\u2011downtime CI\/CD to a VPS with rsync + symlinks<\/a> and <a href=\"https:\/\/www.dchost.com\/blog\/en\/laravel-vps-deployment-nginx-php-fpm-horizon\/\">deploying Laravel on a VPS with Nginx, PHP-FPM and Horizon<\/a> are relevant deployment reading. Using <code>opcache.validate_timestamps=0<\/code> still requires a reliable cache-refresh step for deployments and rollbacks.<\/p>\n<h3><span id=\"opcachemax_wasted_percentage\">opcache.max_wasted_percentage<\/span><\/h3>\n<p>Invalidated cached scripts can leave wasted shared memory. <strong>opcache.max_wasted_percentage<\/strong> is the wasted-memory threshold used in conditional restart scheduling when memory or hash capacity is exhausted. Crossing the threshold alone does not trigger periodic defragmentation.<\/p>\n<p>Values such as <strong>5 or 10<\/strong> are examples to evaluate; the next snippet uses 5:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">opcache.max_wasted_percentage=5<\/code><\/pre>\n<p>Lower values can make a restart eligible at a smaller wasted-memory percentage when exhaustion conditions apply; they do not independently keep fragmentation under control. Treat 5% as a starting point to evaluate, not an optimum for every WordPress or Laravel application.<\/p>\n<h3><span id=\"opcachesave_comments\">opcache.save_comments<\/span><\/h3>\n<p>Some tools parse PHP doc comments for annotations. <strong>opcache.save_comments<\/strong> controls whether OPcache preserves those comments. Native PHP attributes are structured metadata, and type declarations are language syntax; neither is a doc comment.<\/p>\n<ul>\n<li><strong>1 (recommended):<\/strong> keep doc comments available to tools that inspect them<\/li>\n<li><strong>0:<\/strong> slightly less memory usage, but can break frameworks or tools that inspect docblocks<\/li>\n<\/ul>\n<p>To preserve compatibility with tools that parse doc-comment annotations, use this baseline:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">opcache.save_comments=1<\/code><\/pre>\n<h3><span id=\"opcachefile_update_protection\">opcache.file_update_protection<\/span><\/h3>\n<p>This setting prevents caching files younger than the configured number of seconds, protecting against incompletely updated files. Use <code>opcache.file_update_protection=0<\/code> only when every file update is verified to publish complete files atomically. Local SSD\/NVMe storage alone is not sufficient; the atomic-update requirement applies to both local and remote filesystems.<\/p>\n<ul>\n<li><strong>Verified atomic file updates:<\/strong> <code>opcache.file_update_protection=0<\/code> can be considered when every updated file becomes visible only after it is complete.<\/li>\n<li><strong>Other deployments, on local or remote storage:<\/strong> retain the default <code>opcache.file_update_protection=2<\/code> and verify the update procedure. A file-age delay does not repair a corrupted cache or make a multi-file release atomic.<\/li>\n<\/ul>\n<h3><span id=\"opcacherestrict_api\">opcache.restrict_api<\/span><\/h3>\n<p>This optional setting restricts OPcache API functions (<code>opcache_reset<\/code>, <code>opcache_invalidate<\/code>, etc.) by the executing script\u2019s path prefix. It is not user authentication or an HTTP access rule. For a directory-specific prefix, include the trailing slash so a similarly named sibling directory does not also match; keep the deployment directory and its access separately controlled.<\/p>\n<p>Example:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">opcache.restrict_api=&quot;\/var\/www\/deploy-scripts\/&quot;<\/code><\/pre>\n<h3><span id=\"JIT_opcachejit_and_opcachejit_buffer_size\">JIT: opcache.jit and opcache.jit_buffer_size<\/span><\/h3>\n<p>PHP 8 introduced JIT (Just\u2011In\u2011Time compilation) as part of OPcache. JIT can speed up CPU\u2011heavy numeric or algorithmic workloads, but for typical WordPress and WooCommerce sites it often brings little benefit and sometimes complicates debugging.<\/p>\n<ul>\n<li><strong>Classic WordPress \/ WooCommerce:<\/strong> safe to keep JIT disabled:<\/li>\n<\/ul>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">opcache.jit=0\nopcache.jit_buffer_size=0<\/code><\/pre>\n<ul>\n<li><strong>Laravel APIs with CPU-heavy PHP loops or calculations:<\/strong> JIT <em>might<\/em> help, but benchmark the real workload before enabling it. Work already performed inside native image-processing extensions is not automatically accelerated by PHP JIT.<\/li>\n<\/ul>\n<p>If you plan a broader PHP 8.x tuning project, our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/the-php-8-x-upgrade-checklist-the-friendly-guide-to-backwards-compatibility-opcache-preload-and-fpm-pool-tuning-for-wordpress-laravel\/\">the PHP 8.x upgrade checklist (OPcache preload and FPM pool tuning)<\/a> gives a wider context.<\/p>\n<h2><span id=\"Recommended_OPcache_Configurations_by_Stack\">Recommended OPcache Configurations by Stack<\/span><\/h2>\n<h3><span id=\"1_WordPress_WooCommerce_on_Shared_Hosting\">1) WordPress &amp; WooCommerce on Shared Hosting<\/span><\/h3>\n<p>On shared hosting, global php.ini changes usually require the hosting administrator. CGI\/FastCGI deployments may allow selected overrides through <code>.user.ini<\/code> or a control panel; INI_SYSTEM directives such as OPcache memory size and CLI enablement cannot be set in .user.ini. Available RAM and PHP process isolation depend on the hosting plan.<\/p>\n<p>In this environment, ask the hosting administrator which settings are available before using this example:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">; Administrator-managed php.ini example, not a .user.ini file\n; Enable OPcache for web only\nopcache.enable=1\nopcache.enable_cli=0\n\n; Modest memory for many small sites\nopcache.memory_consumption=128\nopcache.interned_strings_buffer=8\nopcache.max_accelerated_files=10000\nopcache.max_wasted_percentage=10\n\n; Check timestamps on requests, subject to revalidate_freq\nopcache.validate_timestamps=1\nopcache.revalidate_freq=60\nopcache.file_update_protection=2\n\n; Safer defaults\nopcache.save_comments=1\nopcache.enable_file_override=0\n\n; JIT off\nopcache.jit=0\nopcache.jit_buffer_size=0<\/code><\/pre>\n<p>You will not have full control over all values on most shared plans, but understanding these directives helps you read the hosting provider\u2019s defaults and decide when it is time to move resource\u2011hungry stores to a VPS. If you frequently hit &#8220;Resource Limit Reached&#8221; or see high TTFB during campaigns, combine OPcache tuning with the strategies in our guide on <a href=\"https:\/\/www.dchost.com\/blog\/en\/shared-hosting-to-vps-sizing-and-migration\/\">moving from shared hosting to a VPS without downtime<\/a>.<\/p>\n<h3><span id=\"2_WordPress_WooCommerce_on_a_VPS_or_Dedicated_Server\">2) WordPress &amp; WooCommerce on a VPS or Dedicated Server<\/span><\/h3>\n<p>Once you control your own PHP\u2011FPM pools and php.ini, you can allocate more memory to OPcache and tighten timestamp checks. For a typical 2\u20134 vCPU, 4\u20138 GB RAM NVMe VPS hosting a few WordPress and WooCommerce sites, an example starting point to evaluate is:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">opcache.enable=1\nopcache.enable_cli=0\n\n; More generous memory\nopcache.memory_consumption=256\nopcache.interned_strings_buffer=16\nopcache.max_accelerated_files=20000\nopcache.max_wasted_percentage=5\n\n; File change detection\n; Select the request-time check interval for the deployment workflow\nopcache.validate_timestamps=1\nopcache.revalidate_freq=30\nopcache.file_update_protection=2\n\nopcache.save_comments=1\nopcache.enable_file_override=0\n\n; JIT disabled for typical WooCommerce\nopcache.jit=0\nopcache.jit_buffer_size=0<\/code><\/pre>\n<p>On multi\u2011tenant VPS setups where each site has its own PHP\u2011FPM pool, budget for OPcache shared memory alongside PHP worker memory and FPM process counts so that the total fits into available RAM. For more server-tuning topics, visit the <a href=\"https:\/\/www.dchost.com\/blog\/en\/\">DCHost blog<\/a>.<\/p>\n<h3><span id=\"3_Laravel_on_a_VPS_or_Dedicated_Server\">3) Laravel on a VPS or Dedicated Server<\/span><\/h3>\n<p>Laravel applications can contain many PHP files (framework + vendor + app code). For a large codebase, consider higher <code>max_accelerated_files<\/code> and <code>memory_consumption<\/code> values based on measured cache usage.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">opcache.enable=1\n; Decide per project whether CLI caching is useful\nopcache.enable_cli=0\n\nopcache.memory_consumption=256 ; or 512 for large apps\nopcache.interned_strings_buffer=16\nopcache.max_accelerated_files=40000\nopcache.max_wasted_percentage=5\n\n; Advanced: requires a tested correct-runtime cache update on deployment\nopcache.validate_timestamps=0\nopcache.revalidate_freq=0\nopcache.file_update_protection=2\n\nopcache.save_comments=1\nopcache.enable_file_override=0\n\n; JIT off unless you tested and measured benefits\nopcache.jit=0\nopcache.jit_buffer_size=0<\/code><\/pre>\n<p>With <code>opcache.validate_timestamps=0<\/code>, periodic timestamp revalidation is disabled and <code>opcache.revalidate_freq<\/code> is ignored. Compile-time checks can still occur when file-update protection or maximum-file-size settings require them. The deployment must deliberately update the correct application cache and restart long-lived application processes as needed; a symlink switch alone does not prove every process uses the new release.<\/p>\n<ul>\n<li>Identify the PHP-FPM master and actual service name serving the application, then use its tested graceful reload procedure. FPM documents reloading all workers of that master; there is no generic pool-specific reload. Account for other applications sharing it.<\/li>\n<li>If deployment tooling uses <code>opcache_reset()<\/code>, run it in the correct serving cache context behind administrator-only access. A separate CLI invocation does not reset the web cache. Coordinate resolved-path caches and long-lived workers, then verify the new release through application requests; do not publish a reset endpoint.<\/li>\n<\/ul>\n<p>This aligns nicely with the production tune\u2011up we describe in <a href=\"https:\/\/www.dchost.com\/blog\/en\/laravel-production-optimization\/\">our Laravel production optimization guide (PHP\u2011FPM pools, OPcache, Octane, queues and Redis)<\/a>.<\/p>\n<h2><span id=\"How_OPcache_Interacts_with_PHPFPM_JIT_and_Application_Caches\">How OPcache Interacts with PHP\u2011FPM, JIT and Application Caches<\/span><\/h2>\n<h3><span id=\"OPcache_and_PHPFPM_Pools\">OPcache and PHP\u2011FPM Pools<\/span><\/h3>\n<p>On most Linux servers, OPcache runs in shared memory per PHP\u2011FPM master process. Each pool shares the same OPcache instance by default. That means:<\/p>\n<ul>\n<li>Raising <code>opcache.memory_consumption<\/code> increases shared memory for <em>all<\/em> pools<\/li>\n<li>A graceful reload affects the workers of the selected FPM master. Verify the resulting in-memory cache and new release; a separately configured file cache means a blanket \u201cevery script recompiles on first use\u201d promise is inappropriate.<\/li>\n<\/ul>\n<p>When designing multi\u2011tenant hosting (many sites, one server), combine OPcache sizing with PHP\u2011FPM limits and PHP <code>memory_limit<\/code>. If a WooCommerce site uses 512 MB of PHP memory per request and you allow many FPM children, OPcache memory becomes relatively small in that picture. The balance across OPcache, <code>memory_limit<\/code> and process counts is often more impactful than any single directive.<\/p>\n<h3><span id=\"OPcache_vs_Object_Cache_RedisMemcached\">OPcache vs Object Cache (Redis\/Memcached)<\/span><\/h3>\n<p>OPcache stores compiled PHP code. Object caches store application data (e.g. query results and options). Both are important but solve different problems. A Redis or Memcached object-cache integration does not automatically configure application session storage.<\/p>\n<ul>\n<li>OPcache reduces CPU time spent parsing and compiling PHP<\/li>\n<li>Object cache reduces database queries and expensive computations<\/li>\n<\/ul>\n<p>For serious WooCommerce or Laravel apps, you usually want both. To understand the data\u2011side caching piece better, you can read our guide on <a href=\"https:\/\/www.dchost.com\/blog\/en\/php-session-cache-files-redis-memcached\/\">choosing PHP session and cache storage (files vs Redis vs Memcached)<\/a> and our detailed <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-object-cache-with-redis-or-memcached-step-by-step-for-shared-hosting-and-vps\/\">WordPress object cache setup with Redis or Memcached<\/a>.<\/p>\n<h3><span id=\"OPcache_and_JIT_in_Real_Projects\">OPcache and JIT in Real Projects<\/span><\/h3>\n<p>Use profiling to distinguish CPU\u2011heavy PHP execution from disk I\/O, database delays, slow plugins and network latency. Do not treat enabling JIT as a substitute for finding the bottleneck. For e\u2011commerce and content sites, a conservative starting point is:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">opcache.jit=0\nopcache.jit_buffer_size=0<\/code><\/pre>\n<p>For compute\u2011heavy Laravel workloads, test JIT in a staging environment with realistic load tests (for example, using the techniques described in our article about <a href=\"https:\/\/www.dchost.com\/blog\/en\/load-test-hosting-with-k6-jmeter-and-locust\/\">load testing hosting with k6, JMeter and Locust<\/a>). If you see a clear, reproducible gain and stable behavior, you can enable it selectively.<\/p>\n<h2><span id=\"Monitoring_and_Debugging_OPcache_in_Production\">Monitoring and Debugging OPcache in Production<\/span><\/h2>\n<h3><span id=\"Checking_OPcache_Configuration_and_Status\">Checking OPcache Configuration and Status<\/span><\/h3>\n<p>Use the command below as an initial configuration check; do not treat its output alone as proof that the web application uses the expected settings. The php command inspects the CLI SAPI, which may load different configuration and has a separate cache from PHP-FPM.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">php -i | grep -i opcache<\/code><\/pre>\n<p>For a status check, use a small script only behind administrator-only access, then remove it when finished. For the web application, run it in the serving PHP context; an ordinary CLI run inspects only that CLI process and requires OPcache to be loaded with CLI caching enabled. The examples above leave CLI caching disabled.<\/p>\n<pre class=\"language-php line-numbers\"><code class=\"language-php\">&lt;?php\n$status = function_exists(&#039;opcache_get_status&#039;)\n    ? opcache_get_status(false)\n    : false;\nif ($status === false) {\n    echo &quot;OPcache status is unavailable in this runtime.\\n&quot;;\n} else {\n    print_r($status);\n}<\/code><\/pre>\n<p>Useful fields to watch:<\/p>\n<ul>\n<li><strong>memory_usage<\/strong> \u2013 how much of OPcache memory is used\/free<\/li>\n<li><strong>interned_strings_usage<\/strong> \u2013 interned string memory usage<\/li>\n<li><strong>opcache_statistics<\/strong> \u2013 hit rate, number of cached scripts, misses<\/li>\n<\/ul>\n<p>Assess hit rate against the application\u2019s normal workload and warm-up state; there is no universal 99% target. Diagnose byte capacity and key capacity separately: compare <code>memory_usage<\/code> used\/free\/wasted bytes and <code>oom_restarts<\/code> when considering <code>opcache.memory_consumption<\/code>. Compare <code>num_cached_keys<\/code> with <code>max_cached_keys<\/code>, alongside <code>hash_restarts<\/code>, when considering <code>opcache.max_accelerated_files<\/code>. Increase only the constrained resource with enough host RAM; raising the key limit does not add OPcache memory bytes.<\/p>\n<h3><span id=\"Common_OPcacheRelated_Issues\">Common OPcache\u2011Related Issues<\/span><\/h3>\n<ul>\n<li><strong>Code changes not visible:<\/strong> With <code>opcache.validate_timestamps=0<\/code>, use the tested deployment procedure for the serving PHP cache. A separate CLI <code>opcache_reset()<\/code> does not reset PHP-FPM\u2019s cache; identify the actual FPM master and controlled reload or restricted in-context reset mechanism.<\/li>\n<li><strong>Mixed versions after a failed deploy:<\/strong> Do not expose partially uploaded files. Prepare a complete release and validate the switch, path-cache behavior and long-lived process lifecycle. Keep <code>opcache.file_update_protection=2<\/code> unless every file update is verified atomic; local storage alone does not justify 0, and the delay does not make a whole release atomic.<\/li>\n<li><strong>High CPU spikes despite OPcache:<\/strong> Profile the application and examine database work, object-cache behavior and PHP-FPM capacity alongside OPcache metrics.<\/li>\n<\/ul>\n<h3><span id=\"Small_OPcache_Status_Dashboard\">Small OPcache Status Dashboard<\/span><\/h3>\n<p>For teams that prefer a visual overview, you can adapt a small, password\u2011protected dashboard page that calls <code>opcache_get_status()<\/code> and renders key metrics. Run it in the intended serving PHP context, handle unavailable status, and keep it inaccessible to the public because it can expose path and environment information.<\/p>\n<h2><span id=\"Safe_Deployment_Workflow_with_OPcache_Enabled\">Safe Deployment Workflow with OPcache Enabled<\/span><\/h2>\n<p>Misaligned deployment and OPcache settings are a common source of &#8220;it works on some requests but not others&#8221; problems. A robust workflow usually follows these principles:<\/p>\n<ol>\n<li><strong>Build\/compile assets elsewhere<\/strong> (CI, local) so production only receives ready\u2011to\u2011run PHP and static files.<\/li>\n<li><strong>Deploy to a new release directory<\/strong>, e.g. <code>\/var\/www\/myapp\/releases\/2025-01-01-120000<\/code>.<\/li>\n<li><strong>Update a symlink<\/strong>, e.g. <code>\/var\/www\/myapp\/current<\/code> \u2192 new release, atomically.<\/li>\n<li><strong>Update the correct serving runtime<\/strong>: use the verified FPM master\/service lifecycle, or restricted <code>opcache_reset()<\/code> execution in that cache context. Cover resolved-path caches and long-lived workers separately, and verify the intended release through application requests. Apply the same procedure on rollback.<\/li>\n<\/ol>\n<p>Before using <code>validate_timestamps=0<\/code>, verify that deployment and rollback activate the intended release consistently across all serving instances. Validate request handling during release transitions before describing the workflow as zero\u2011downtime. We use a similar pattern in our guides on <a href=\"https:\/\/www.dchost.com\/blog\/en\/zero-downtime-ci-cd-to-a-vps-the-friendly-rsync-symlink-systemd-playbook-i-keep-reusing\/\">zero\u2011downtime CI\/CD to a VPS<\/a> and <a href=\"https:\/\/www.dchost.com\/blog\/en\/laravel-vps-deployment-nginx-php-fpm-horizon\/\">Laravel deployments with Nginx, PHP\u2011FPM and Horizon<\/a>.<\/p>\n<h2><span id=\"Putting_It_All_Together_Practical_Checklists\">Putting It All Together: Practical Checklists<\/span><\/h2>\n<h3><span id=\"Checklist_for_WordPress_WooCommerce\">Checklist for WordPress \/ WooCommerce<\/span><\/h3>\n<ul>\n<li>Verify <code>opcache.enable=1<\/code> in the PHP runtime actually serving each site.<\/li>\n<li>Treat <code>opcache.memory_consumption<\/code> values such as 128 or 256 MB as examples to evaluate against measured byte usage and available RAM.<\/li>\n<li>Choose <code>opcache.max_accelerated_files<\/code> from measured key usage and the effective prime-rounded limit, not an assumed plugin count.<\/li>\n<li>Keep <code>opcache.save_comments=1<\/code> for packages relying on doc-comment annotations.<\/li>\n<li>Where files can change through plugins, themes, panels or other paths outside a controlled release workflow, retain <code>opcache.validate_timestamps=1<\/code> and choose <code>opcache.revalidate_freq<\/code> with the administrator.<\/li>\n<li>Consider disabling periodic validation only if every production code-change path and rollback uses a tested release and correct-cache update procedure. A standalone CLI reset does not satisfy this.<\/li>\n<li>Keep JIT off unless realistic profiling and tests justify enabling it.<\/li>\n<\/ul>\n<h3><span id=\"Checklist_for_Laravel\">Checklist for Laravel<\/span><\/h3>\n<ul>\n<li>Size <code>opcache.max_accelerated_files<\/code> using actual framework, vendor and application key usage; check the effective capacity.<\/li>\n<li>Evaluate illustrative 256\u2013512 MB <code>opcache.memory_consumption<\/code> values against byte usage and host memory.<\/li>\n<li>Disable periodic timestamp validation only when all production code changes and rollbacks use a tested complete-release workflow that updates the correct serving cache, resolved-path state and long-lived workers. CI\/CD availability alone is insufficient.<\/li>\n<li>Keep <code>opcache.save_comments=1<\/code> for packages using doc-comment annotations.<\/li>\n<li>Measure whether <code>opcache.enable_cli=1<\/code> benefits the actual long-running workload; independent fresh Artisan invocations do not share a warm in-memory cache by default.<\/li>\n<li>Benchmark JIT for CPU-heavy PHP execution; native extension work is not automatically accelerated.<\/li>\n<\/ul>\n<h2><span id=\"Final_Thoughts_and_Next_Steps\">Final Thoughts and Next Steps<\/span><\/h2>\n<p>OPcache tuning should be guided by measurements from your workload. For WordPress, WooCommerce and Laravel, the right configuration can shave precious milliseconds from each request, reduce CPU load during peak campaigns and give you more breathing room before you need to scale up hardware. The key is to treat OPcache as part of a broader stack: aligned with PHP\u2011FPM pools, PHP memory limits, database tuning and, when needed, Redis or Memcached caches.<\/p>\n<p>Treat these OPcache patterns as starting points, adapting values to each project\u2019s size and traffic profile. If you are unsure where your current bottleneck is \u2013 OPcache, PHP\u2011FPM, MySQL, or storage \u2013 you can always start by measuring, then adjust one layer at a time. Use the baselines in this guide, watch OPcache stats under real traffic, and refine. If you need help with low\u2011level tuning, establish who is responsible for PHP configuration and deployment support under your hosting agreement.<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Evaluate OPcache baselines for WordPress, Laravel and WooCommerce. Learn how to size memory and key capacity, monitor the serving PHP runtime, and align cache refreshes with deployments and rollbacks.<\/p>\n","protected":false},"author":1,"featured_media":13009,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[184],"tags":[],"class_list":["post-3722","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/comments?post=3722"}],"version-history":[{"count":7,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3722\/revisions"}],"predecessor-version":[{"id":13011,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3722\/revisions\/13011"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media\/13009"}],"wp:attachment":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media?parent=3722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/categories?post=3722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/tags?post=3722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}