开发者

Codeigniter: managing what to cache on each controller output

开发者 https://www.devze.com 2023-02-14 22:32 出处:网络
Good sunday everyone! I just started playing with codeigniter, up to now everything seems so clear (great docs!), but i\'m trying to understand how works $this->output->cache().

Good sunday everyone! I just started playing with codeigniter, up to now everything seems so clear (great docs!), but i'm trying to understand how works $this->output->cache().

What i wanto to do is to cache only some comp开发者_如何学Goonent of my interface. For example, in my controller i load a view for each part of the structure: header_view, topnav_view, sidebar_view and home_view.

Using $this->output->cache(n) in my controller i get cached the whole page. What if i want to cache the whole page except the header_view?


CodeIgniter Reactor (2.0) has that feature built-in. I suggest you use CodeIgniter Reactor's latest release.

CodeIgniter Reactor is the community branch of the somewhat - until recently - neglected project from EllisLab. It is officially sponsored with "community stewards" who guide the development and ensure that the coding standards are followed. It contains many new features and is much farther along than previous releases of CodeIgniter (1.7.3). Yet it's cut from the same cloth so to speak as it is a branch of the official CI source.


Use Phil Sturgeon's cache library to cache as much (or as little) of the page as you want.

I generally just use the get/write/delete functions to cache the non-user-specific database reads (from multiple model calls) for my pages. But do consider the model/library and dependency functionality if it works in your case

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号