Flush the PHP OPcache

Gewijzigd op Di, 4 Aug om 11:07 AM

Flush the PHP OPcache

The PHP OPcache increases the performance of your shop by caching processed PHP source code in memory. The Savvii servers are configured to re-read a script when it is changed.


However, if you use a deploy method which switches to a new version of the code by replacing a symlink to a new release, PHP does not detect the change. This will cause strange things to happen.


If you use a deployment method which changes one or more symlinks to point to the new version of the PHP code, you will need to flush the OPcache.


Easy & Recommended: Reload PHP using SSH

Execute this line in [SSH](ssh access link), or preferably, in a script after the deploy to flush the PHP OPcache:

$HOME/bin/reload_php.sh

Note: if you are running our mh_queue_consumer.service, this will also be restarted with above script.


Advanced: Web Script

Create a file ~/httpdocs/flush_php.php containing:

<?php
opcache_reset();
clearstatcache(1);
echo "OK";


You can call this script in a browser or you can call it in an SSH shell:

curl -Lk "https://$VHOSTDOMAIN/flush_php.php"


In case this does not work because of domain issues, you can try:

curl -Lk "http://$VHOSTIP/flush_php.php"

A web script like this will allow you to flush the cache remotely, it is therefore recommended to restrict access to it using .htaccess

Was dit artikel nuttig?

Dat is fantastisch!

Hartelijk dank voor uw beoordeling

Sorry dat we u niet konden helpen

Hartelijk dank voor uw beoordeling

Laat ons weten hoe we dit artikel kunnen verbeteren!

Selecteer tenminste een van de redenen
CAPTCHA-verificatie is vereist.

Feedback verzonden

We stellen uw moeite op prijs en zullen proberen het artikel te verbeteren