When smarty cache is turned on, the compiled output file will be saved in the cache directory when executed for the first time, and then in the program, the is_cache() function of smarty will be used to detect whether the cache file has expired. If it has expired, The cache will be updated, and if it has not expired, the cache file will be automatically called, thus eliminating the compilation process. Detecting cache expiration is to see whether the template file has changed within the specified life cycle. The change here is achieved by detecting the latest modification time of the file, not by detecting the content of the template file.
Prevent the entire template file from being cached:
index.php file:
function smarty_block_dynamic($param, $content, &$smarty) {
return $content;
}
$smarty->register_block('dynamic', 'smarty_block_dynamic', false);
$smarty->display('index.tpl');
index.tpl:
{dynamic}
now is: {"0"|date_format:"%d %h:%m:%s"}
... do other stuff ...
{/dynamic}
When reloading this page, you will notice that the two dates are different. One is "dynamic" and the other is "static". You can do anything between {dynamic}...{/dynamic} and be sure it won't be cached like the rest of the page.