Overview
This article explains how to enable OPcache and check if it's functioning on your site.
Background
OPcache is a caching engine built into PHP. When enabled, it dramatically increases the performance of websites that utilize PHP. You can read more about Opcache from php.net:
OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.
Viewing and managing the OPcache settings in the panel
To view and make changes to the OPcache settings in your panel:
- Navigate to the Manage Websites page.
- Click the Manage button to open Website settings, which allows you to modify various configurations for your site.
- Select the Settings tab.
-
Next to PHP, click the Manage button.
The PHP Settings page opens.
-
Scroll down to the OPcache section and click the Modify button.
The OPcache settings exapands, showing you various values to adjust.
- Make any adjustments to the values as needed. See the next sections for further information.
- Click the Save Changes button when finished.
Please, keep in mind that OPache is enabled by default on Shared Hosting plans. The settings shown in this section are informational only and cannot be modified.
OPache settings
The following settings are displayed with their current values:
- memory_consumption — Maximum memory reserved for OPcache.
- max_accelerated_files — Maximum number of PHP files that can be cached at once.
- interned_strings_buffer — Memory reserved for storing repeated strings to improve efficiency.
Advanced settings
Click the Advanced Settings button to view additional configuration options.
- file_cache_only — Uses file-based caching instead of shared memory.
- file_update_protection — Delay before newly updated files are cached.
- force_restart_timeout — Time to wait before forcing a cache restart if needed.
- max_file_size — Maximum file size that will be cached.
- max_wasted_percentage — Percentage of wasted memory before the cache is reset.
- revalidate_freq — How often PHP checks for file changes.
- validate_timestamps — Enables checking for updated files.
- huge_code_pages — Enables advanced memory optimization for performance.
Keep in mind that the available settings may vary depending on the PHP version selected for your domain.
How to enable OPcache
The following sections provide information on how to enable OPcache on specific DreamHost plans.
Shared, DreamPress, or Managed VPS
OPcache is already enabled by default on Shared, DreamPress, and Managed VPS hosting plans.
Dedicated Server
OPcache is already compiled with PHP. To enable it on your Dedicated Server site, create a php.ini file and add the following:
zend_extension=opcache.so
WordPress and DreamPress
You can use OPcache with either WordPress or DreamPress:
- DreamPress — OPcache is enabled by default, which you can see in a phpinfo.php file as described below.
- WordPress plugin — The WP OPcache plugin is useful to flush OPcache easily.
How to check if OPcache is functioning
There are a few different ways you can check if OPcache is functioning, which are described in the following sections.
Checking with a phpinfo.php file
You can confirm if OPcache is functioning by creating and viewing a phpinfo.php file. See this article for further details.
If you do not see OPcache listed in the file, see this article for guidance.
Checking via the command line
To see if the module was installed correctly, you can run the following command. Just specify the full path for your desired version of PHP:
[server]$ /usr/local/php84/bin/php -i | grep opcache
You should see the OPcache settings appear.
Using a runtime configuration
See this page for a list of available runtime configurations you can use.
See also
DreamHost links
Third-party links