zazvorniki
zazvorniki

Reputation: 3602

Codeigniter caching?

I'm trying to make my site faster, because I want it to load as fast as posable. I'm having a bit of trouble with caching though. I was trying to work with this, but it seems that that caches the whole page and my content changes quite a bit. Is it possible for me to only cach certain views that I know will not be changing? Like the header, footer and the main home page.

Upvotes: 4

Views: 10988

Answers (3)

Chris
Chris

Reputation: 6182

A little late to the conversation, but have you taken a look at database cache? A lot of the web page delay can come from heavy db queries. Caching the results opens up dynamic views.

This is helpful when you are managing sessions.

$this->db->cache_on();

Place this in your model instead of controller. Make sure you have a writable db-cache folder in your app directory as well.

Upvotes: 0

exussum
exussum

Reputation: 18550

using extentions this is possible

https://github.com/philsturgeon/codeigniter-cache

usually the displaying isue too much of an issue, its the generation of the data which needs to be displayed which takes longer and benefits most from caching.

Upvotes: 2

Shomz
Shomz

Reputation: 37701

The point of CI caching is to reduce the number of database queries, any time-consuming PHP calculations, etc... Basically, it will render a plain HTML page from your controller (and all the views it calls, of course). So, it won't really speed up your header and footer, unless you pull the data for them from the database or anythings that dynamic and heavy... but any modern browser will cache that for you unless you specifically disallow caching.

So, the bottom line, CI caching allows caching of the full pages only, no separate parts. Of course, there are alternative ways to achieve what you wanted, for example you can make the header and the footer separate controllers, put caching in them, and call them by AJAX... but I'm not sure it's worth it.

Upvotes: 4

Related Questions