ANS Documentation

Improve This Doc
  • Cloud
  • Domains and DNS management
  • Backup and High Availability
  • eCommerce Stacks
    • Magento
      • Magento 1
      • Magento 2
    • Shopware
    • WooCommerce
    • AeroCommerce
  • Security
  • Email
  • Monitoring and usage management
  • Networking
  • Operating systems
  • Webcelerator
  • MyUKFast
  • Home >
  • eCommerce Stacks >
  • Magento >
  • Magento 1 >
  • OPCache >
  • OPcache

OPcache¶

OPcache will cache .php and .phtml files within your Magento application. Therefore you should add flushing OPcache to your deployment process.

Version Check¶

You can check the version of OPcache installed with the command:

~]# php -v | grep -i opcache
    with Zend OPcache v7.2.19, Copyright (c) 1999-2018, by Zend Technologies

Module Check¶

You can confirm the module has been loaded:

~]# php -m | grep -i opcache
Zend OPcache

Flush OPcache¶

Service Reload¶

You can flush OPcache with a reload of the PHP-FPM service, always run a configuration test before reloading

~]# php-fpm -t
[19-Aug-2019 08:48:54] NOTICE: configuration file /etc/php-fpm.conf test is successful
~]# systemctl reload php-fpm

PHP Function¶

You can also clear OPcache using the PHP function:

<?php
 opcache_reset();
?>

Stack OPcache settings¶

We use the following sed to change the default settings of OPcache on our Magento 1 stacks:

sed -i 's/opcache.memory_consumption=128/opcache.memory_consumption=512/g' /etc/php.d/*opcache.ini
sed -i 's/opcache.interned_strings_buffer=8/opcache.interned_strings_buffer=12/g' /etc/php.d/*opcache.ini
sed -i 's/opcache.max_accelerated_files=4000/opcache.max_accelerated_files=60000/g' /etc/php.d/*opcache.ini
sed -i 's/;opcache.save_comments=1/opcache.save_comments=0/g' /etc/php.d/*opcache.ini
sed -i 's/;opcache.load_comments=1/opcache.load_comments=0/g' /etc/php.d/*opcache.ini
sed -i 's/;opcache.enable_file_override=0/opcache.enable_file_override=1/g' /etc/php.d/*opcache.ini

This changes the values to:

opcache.memory_consumption=512
opcache.interned_strings_buffer=12
opcache.max_accelerated_files=60000
opcache.max_accelerated_files=60000
opcache.load_comments=0/
opcache.enable_file_override=1

OPcache GUI¶

The OPcache GUI https://github.com/amnuts/opcache-gui is a very handy tool which allows you to flush cache, view the files in cache, memory statistics and lots more. You simply need to download the files to your document root:

~]# cd /var/www/vhosts/magentodomain.com/htdocs/
~]# git clone https://github.com/amnuts/opcache-gui
~]# chown -R magentouser: opcache-gui

You can then browse www.magentodomain.com/opcache-gui. We recommend password / IP redirection for this URI, we have guides on how to do this here

Next Article > PHP

  • Useful Links
  • SMB
  • Enterprise
  • Channel
  • Public Sector
  • ANS Data Centres
  • About ANS
  • Careers
  • Blog
  • Get in touch
  •  
  • Sales 0800 458 4545
  • Support 0800 230 0032
  • Get in touch

© ANS Group Limited | Terms and Conditions | Corporate Guidance | Sitemap
ANS Group Limited, registered in England and Wales, company registration number 03176761, registered office 1 Archway, Birley Fields, Manchester M15 5QJ