false,"; 3. Configure "'TMPL_CACHE_ON' => false," in config.php to turn off the template cache."/> false,"; 3. Configure "'TMPL_CACHE_ON' => false," in config.php to turn off the template cache.">

Home >PHP Framework >ThinkPHP >How to disable caching in thinkphp5

How to disable caching in thinkphp5

藏色散人
藏色散人Original
2022-12-07 10:36:512373browse

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);

#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,      // 默认开启模板缓存

convention.php中

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

3. Turn off the template cache and configure

'TMPL_CACHE_ON' => false,
'TMPL_CACHE_ON' => false,

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!

Statement:
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