You can set it in display
$smarty->display("demo.tpl",$_SERVER[REQUEST_URI]) to achieve multiple caches for one template.
Now that the file has been cached, we can cache the file without looping to connect to the database and perform queries. Use a function in smatry to judge
$smarty->iscached(demo.tpl"",",$_SERVER[REQUEST_URI]) The default value is "true" The template here should be the same as the display.
There is a difference between smarty3 and smarty2
$smarty->is_cached(demo.tpl"",",$_SERVER[REQUEST_URI]) smarty2
$smarty->iscached(demo.tpl"",",$_SERVER[REQUEST_UR]I) smarty3
But there are some parts in the template that do not need to be cached, such as: user login, and article The comment section does not need to be cached, so we solve it like this:
1. In the php file, if the data does not need to be cached, it should be placed outside the iscached judgment.
2. In the template. If the part that does not need to be cached is placed between <{nocache}>.........<{/nocache}>.