My application allows registered users to post stuff. On the top bar, like many social apps, when logged in one can see their avatar etc.
My issue is that the user-specific content in the header gets cached when using CodeIgniter’s output cache.
This is because first I load user-specific logic via a MY_Controller, which is then extended by all other controllers.
When I place
$this->output->cache(MINUTES);
in the controller that loads my home page, it also ends up caching the avatar and name of the user that generated that cached page.
Does anyone have a suggestion on what would be the best way to selectively cache only the public content? Glad to post more code if needed.
I’m sure someone will correct me if I’m wrong but I believe codeigniter caching only allows the caching of full pages. There are some additional libraries which enable partial page caching, check out phil sturgeons effort here:
http://getsparks.org/packages/cache/show
My personal approach is to not bother with page caching and just use database caching which is more selective – but if you want/need page caching then I think the above is the only way to go