Home >Backend Development >PHP Problem >How to clear opcache cache in php
php method to clear opcache cache: 1. Modify the php.ini file in the development environment and change the value of "opcache.revalidate_freq" to 1; 2. In the online environment, you can execute " opcache_reset();" code to restart the web server.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
1, php.ini default configuration
opcache.validate_timestamps=1 opcache.revalidate_freq=2 //默认每隔2s会验证改变的文件并会更新缓存
2. Application situation
When debugging in the online environment, if the code is updated, it will not take effect immediately. It will take effect after the cache is updated. Inconvenient for debugging
3. Solution
1), development environment:
will be modified to:
opcache.revalidate_freq=1 //可以将2s改成1s每隔1s会验证改变的文件并会更新缓存
2) , Online environment:
opcache.validate_timestamps=0 //线上环境默认是不开启,不开启的话,会一直用缓存
The following two methods:
a. Add
<?php opcache_reset(); ?>
b to the entry file. Restart the web server
Recommended learning: " PHP video tutorial》
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!