缓存

 

Smarty中的缓存

1、        一个页面一个缓存

2、        一个页面多个缓存(分页)

3、        局部关闭缓存(实时性)

缓存的目的:

PHP文件:解决功能上的问题(M+C)

          提供数据

HTML文件:界面效果(V)

缓存的配置步骤:

1)   配置文件中开启缓存

$tpl->caching=2

缓存时间(秒)

缓存目录

     2)$tpl->display(“index.tpl”);

   相当于把(编译后的文件产生的)静态页面只保留一份;

      $tpl->display(“index.tpl”,名称);

   相当于把(编译后的文件产生的)静态页面根据名称保留多份;

       例如:$tpl->display(“index.tpl”,1);

            $tpl->display(“index.tpl”,$_GET[‘page’]);

 $tpl->display(“index.tpl”,$_SERVER[‘REQUSET_URI’]);

3)        登陆用户名、时间日期等实时性要求比较高需要关闭缓存

l      <{insert }> 关闭缓存

*.php

 Function  insert_XXX(){}

 *.tpl

 <{insert name=XXX assign=XXX}>

l      写插件

./plugins/block.XXX.php

  Function smary_block_XXX(){}

编辑Smarty_compiler.class.php文件

 712行

 true---false

  if($tag_command==XXX){。。。。。。false}

   else{ 。。。。。。。。。。。。。。。。。。。。。。。true}

l      自定义函数

*.php

Function   XXXX(){}

$tpl->register_block(“”,””,false)

 

模板文件

  <{XXX}>  <{$DATE}>  <{XXX}>

 

posted @ 2011-11-22 20:28  Java EE  阅读(218)  评论(0编辑  收藏  举报