Purging OpCache
Table of Contents
The use of OpCache on MageStack is sparing and not aggressive. Which means that it will maintain its own cache contents, updating the entries as necessary, instantly.
It is extremely rare that you'll ever need to clear OpCache except in two circumstances,
- If you use a symlink for the root directory of your document root and the symlink changes destination
- If you have active overflows or multiple web nodes and you deploy a code change
In these circumstances, it is possible that OpCache won't detect the file changes and as such, it may be required to clear OpCache.
Purging
Purging OpCache is very straightforward and can be tied into deployment scripts,
/usr/bin/php /microcloud/scripts/classes/Opcache.php --lb lb1 --host www.example.com
Replace lb1
and www.example.com
with your load balancer node and domain as necessary.
The response is in JSON format confirming all nodes have been successfully purged, in a multi-server stack, or where overflows are provisioned, you'll also see the additional web servers automatically listed.
Example Response
[
{
"status": "success",
"message": "Opcache successfully cleared",
"hostname": "web1.c1.sonassihosting.com"
}
]
Alternative
If you're seeing issues with opcache not being cleared whilst running a deployment, there's also the option of restarting the PHP service instead (as this will clear opcache as a side effect).To do this, run:
/etc/init.d/web-php restart web1
Run this multiple times for each web node on your stack, replacing web1
with the value of each web node.
To confirm the web nodes that are active, visit your stack's HAProxy status page at https://haproxy.magestack.com/ (requires stack VPN), then check the web values that're highlighted green under the "frontend-output-dynamic" section.