I have setup my website on a new hosting (virtual cloud), however I am looking at the opcache and the scripts
not being used for say a minutes or so
are removed from the cache.
So is there a way to stop it? or is it a normal behaviour?
Thanks a lot.
To flush PHP Opcache on the PHP-FPM method, you have to send a reload to your PHP-FPM daemon. The reload will clear the Opcache, and when the next request arrives, it will force it to rebuild the cache. You can flush the entire cache of all the websites by reloading the single master.
If your server has PHP 5.5 or higher, you will see an in the admin bar to Purge OPcache. You can read on the PHP manual to know more about OPcache: 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.
OPcache is a type of caching system that saves precompiled script bytecode in a server's memory called a cache, so each time a user visits a web page, it loads faster. Here's more detail on OPcache and how to install it for your WordPress site to speed it up.
There is configuration for that actually.
opcache.revalidate_freq=2
, the default value is 2 seconds, opcache will try to check for timestamps every 2 seconds and if the files are changed it will revalidate.
You can change the value to match your needs, or you can just turn timestamp check off using this conf opcache.validate_timestamps=0
, but in this case each time you deploy code to production you have to restart php-fpm (if you are using php-fpm) and web server
opcache.revalidate_freq=2
or any integer value
opcache.validate_timestamps=1
or opcache.validate_timestamps=0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With