Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opcache clears too quickly

Tags:

php

opcache

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.

like image 808
Raheel Hasan Avatar asked Dec 14 '15 05:12

Raheel Hasan


People also ask

How do I get rid of Opcache?

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.

What is purge Opcache content?

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.

What is opcode caching?

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.


1 Answers

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

like image 97
midan888 Avatar answered Sep 24 '22 19:09

midan888