Home > Backend Development > PHP Problem > How to clear opcache cache in php

How to clear opcache cache in php

青灯夜游
Release: 2023-03-08 14:54:01
Original
3647 people have browsed it

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.

How to clear opcache cache in php

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会验证改变的文件并会更新缓存
Copy after login

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会验证改变的文件并会更新缓存
Copy after login

2) , Online environment:

opcache.validate_timestamps=0 //线上环境默认是不开启,不开启的话,会一直用缓存
Copy after login

The following two methods:

a. Add

<?php 
opcache_reset();
?>
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template