duanpu6319 2010-12-16 01:35
浏览 26

Smarty Caching vs滚动你自己?

As far as I understand it, when you turn on caching in smarty, smarty caches compiled templates. These compiled templates can then used to speed up rendering of the page. Wouldn't it be a good idea to run you own level of caching on top of your smarty application that goes like this.

if(a cache for this page exists){
    -Don't run my application, don't include my files don't instantiate my classes.
    -Send the cached version of this page to the user
    -end the script here
}else{//if the cache for this page does not exist or is not current
  - run my application as usual
  -save all the output to a file for next time
}

The whenever somthing happens on my site that would update the content of the this page, eg the admin makes changes to the content of the site delete the cache file. I feel like I must be missing something here. This method would allow me to store an all html version of every page and send that when it is valid. It seems like this would drastically improve the speed of my site.

Edit: Ok so I have discovered that smarty does infact store a html version of my site. How do I prevent my application from running if the rest of my application from running if the cache is current. Do I just include and instantiate smarty first and do something like

if($smarty->usingcache())[
exit;
}
  • 写回答

2条回答 默认 最新

  • douzong0711 2010-12-16 01:38
    关注

    If your site were static, this would work. But in that case, you wouldn't need Smarty...

    Suppose you update a record in your database. Then all pages in your site which contain output directly or indirectly affected by the update would have to be invalidated. How would you know which pages to invalidate?

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料