Principle of page staticization before smarty cache control

  • 2020-05-30 19:43:53
  • OfStack

This can be set in display

$smarty- > display(" demo.tpl ",$_SERVER[REQUEST_URI]) to implement multiple caches for one template.

Now that the file is cached, we can walk through the cache file and not loop through the connection to the database. Use one of the functions in smatry

$smarty- > iscached(demo.tpl ""," $_SERVER[REQUEST_URI]) defaults to "true" where the template is the same as 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

However, there are parts of the template that do not need to be cached, such as user login, and the comments section of the article, so let's do this

1. In the php file, data that does not need to be cached should be placed outside the iscached judgment.

2. Place the parts of the template that don't need to be cached < {nocache} > ........ < {/nocache} > In between.

Related articles: