Home > Backend Development > PHP Tutorial > Principle of page staticization before smarty cache control_PHP tutorial

Principle of page staticization before smarty cache control_PHP tutorial

WBOY
Release: 2016-07-21 15:12:16
Original
778 people have browsed it

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}>.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326732.htmlTechArticle can be set in display $smarty-display("demo.tpl",$_SERVER[REQUEST_URI]) Implement a template with multiple caches. Now that the file has been cached, we can cache the file...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template