In the case of the Smarty cache, the first execution will save its compiled output file to the cache directory, and then in the program through the Smarty Is_cache () function to detect whether its cache file expires, if the expiration will update the cache, If there is no expiration, the cache file is called automatically, thus eliminating the process of compiling. Detecting cache expiration is to see if the template file has changed over the specified life cycle, where the change was achieved by detecting the file's last modified time, not by detecting the template file contents.
Prevents the entire text of a template file from being cached:
index.php file:
Copy the Code code as follows: Require (' smarty.class.php ');
$smarty = new Smarty;
$smarty->caching = true;
function smarty_block_dynamic ($param, $content, & $smarty) {
return $content;
}
$smarty->register_block (' Dynamic ', ' smarty_block_dynamic ', false);
$smarty->display (' Index.tpl ');
INDEX.TPL:
Copy the Code Code as follows: Page created: {"0" |date_format: "%d%h:%m:%s"}
{Dynamic}
Now is: {"0" |date_format: "%d%h:%m:%s"}
... does other stuff ...
{/dynamic}
When you reload this page, you will notice that the two dates are different. One is "dynamic" and one is "static". You can be in {dynamic} ... Do anything between {/dynamic} and make sure it won't be cached like the rest of the page.
http://www.bkjia.com/PHPjc/825342.html www.bkjia.com true http://www.bkjia.com/PHPjc/825342.html techarticle when the Smarty cache is turned on, the first execution will save its compiled output file to the cache directory and then detect its cache file in the program through the Smarty Is_cache () function ...