7

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.

Raheel Hasan
  • 5,753
  • 4
  • 39
  • 70

2 Answers2

2

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

midan888
  • 179
  • 6
0

Sounds like you need to define validate_timestamps=0 in php.ini. Beware of this though - if you upload any changes to your PHP files you will need to restart either Apache (if you use mod_php5) or PHP5-FPM, or clear the opcache manually.

For details on how to clear the opcache manually you basically have to create a PHP file with opcache_reset() and run it, but this has to be in the same SAPI as your other files - i.e. run by PHP5-FPM if that is what is serving the rest of your files. http://ihaveabackup.net/2013/10/19/invalidating-the-opcache-in-php-5-5/

Benr77
  • 155
  • 1
  • 10