PHP 8 and OPcache: recommended configuration for PrestaShop
A badly tuned PHP makes the best server slow. These are the values we use as a starting point on PrestaShop 8 and 9 stores.
PrestaShop is a large PHP application: thousands of files loaded on every request. That is why the PHP configuration, and OPcache in particular, has a huge impact on speed.
Which PHP version
- PrestaShop 9: PHP 8.1 to 8.4. We recommend 8.3, which is stable and fast.
- PrestaShop 8: PHP 7.2 to 8.1. Use 8.1 if your modules support it.
Before upgrading, test on a copy: old modules can fail on PHP 8 because of removed functions or stricter types.
OPcache: the setting that matters most
opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=32
opcache.max_accelerated_files=40000
opcache.validate_timestamps=1
opcache.revalidate_freq=60
max_accelerated_files: a store with many modules easily exceeds 20,000 PHP files. If the value is low, OPcache fills up and stops caching.memory_consumption: 256 MB is a good starting point. Check withopcache_get_status()that it does not run out.revalidate_freq: how many seconds between checks for changed files. In production, 60 is fine; after a deployment, flush OPcache or wait that long.
Other parameters
memory_limit=512M
max_execution_time=300
max_input_vars=10000
upload_max_filesize=64M
post_max_size=64M
realpath_cache_size=4096K
realpath_cache_ttl=600
max_input_vars is the classic culprit behind forms that “do not save everything”: products with many combinations or large translations send thousands of fields, and PHP silently drops those beyond the limit.
php.ini, in a .user.ini in the root or from the control panel (cPanel, Plesk). On some hosts the .user.ini in the root is what takes precedence, and changes take a few minutes to apply.How to check what is actually applied
PrestaShop shows the PHP configuration in Advanced Parameters > Information. And if you have SSH, php -i | grep opcache gives you the command-line values, which may not match those of the web server: compare both.