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 > Article > PHP Framework > How to disable caching in thinkphp5
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.
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!