The content of this article is about how to clear the opcache cache in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
1. php.ini default configuration
opcache.validate_timestamps=1 opcache.revalidate_freq=2 //默认每隔2s会验证改变的文件并会更新缓存
2. Application situation
During online environment debugging, if the code is updated, it will not take effect immediately and needs to wait. The cache will not take effect until it is updated, which is inconvenient for debugging
3. Solution
Development environment:
will be modified to: opcache.revalidate_freq=1 //You can change 2s Changed files will be verified every 1s and the cache will be updated.
Online environment:
opcache.validate_timestamps=0 //The online environment is not enabled by default. If not, it will Always use caching
The following two methods:
a. Add the entry file, through the function
<?php opcache_reset();?>
b. Restart the web server
Related recommendations:
Yii2 assets clear cache method, yii2assets clear cache
##php clearstatcache - clear file status cache
The above is the detailed content of How to clear opcache cache in php. For more information, please follow other related articles on the PHP Chinese website!