How to clear opcache cache in php

不言
Release: 2023-04-03 19:44:01
Original
6119 people have browsed it

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

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();?>
Copy after login

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!

Related labels:
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