Home > PHP Framework > ThinkPHP > body text

How to disable caching in thinkphp5

藏色散人
Release: 2022-12-07 10:36:51
Original
2333 people have browsed it

How to disable caching in thinkphp5: 1. Add the code "define('DB_FIELD_CACHE',false);" to the entry file; 2. Open "debug.php" and modify the content to "'HTML_CACHE_ON' => ;false,"; 3. Configure "'TMPL_CACHE_ON' => false," in config.php to turn off the template cache.

How to disable caching in thinkphp5

The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.

How to disable caching in thinkphp5?

thinkphp turns off caching:

Be clear: Unless you don’t use tp’s template engine. The so-called turning off the compilation cache here means: with the cache file, recompile it without using the previously generated one.

[All three methods are possible, but how to verify whether the cache is turned off? 】

#Close all caches in the entry file

Add the following lines of code to the entry file:

define('APP_DEBUG',TRUE); // 开启调试模式

define('DB_FIELD_CACHE',false);

define('HTML_CACHE_ON',false);
Copy after login

#Modify the default value from the configuration

1. Find \ThinkPHP\Common\convention.php and \ThinkPHP\Common\debug.php

2. Modify as follows

debug.php in

'TMPL_CACHE_ON'=>false,      // 默认开启模板缓存
Copy after login

convention.php中

'TMPL_CACHE_ON'   => false,  // 默认开启模板编译缓存 false 的话每次都重新编译模板
'ACTION_CACHE_ON'  => false,  // 默认关闭Action 缓存
'HTML_CACHE_ON'   => false,   // 默认关闭静态缓存
Copy after login

3. Turn off the template cache and configure

'TMPL_CACHE_ON' => false,
'TMPL_CACHE_ON' => false,
Copy after login

in config.php. Recommended learning: "thinkPHP Video Tutorial"

The above is the detailed content of How to disable caching in thinkphp5. 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