![]() |
Fragment Caching in CodeIgniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Fragment Caching in CodeIgniter (/showthread.php?tid=15028) |
Fragment Caching in CodeIgniter - El Forum - 01-24-2009 [eluser]CrossMotion[/eluser] I am working on a codeigniter project where I want to have a page build from multiple views of witch only a few are not cached. I am building my controller as following: Code: <?php In this case I would like to cache everything except the login_block. and then of course the global view. the other subvie's can all be cached. Is there a way I can do this, or does someone know a good tutorial featuring partial caching? Fragment Caching in CodeIgniter - El Forum - 01-27-2009 [eluser]CrossMotion[/eluser] I understood that Fragment Caching was a part of the CodeIgnitor framework, but since No one replied till now I guess I was mistaken... Is there someone who can confirm this for me? Also I think this is a quite common problem since most current websites have things like shopping carts and other personal content that we don't want cached.. I am really curious how other people have tackled this problem. Fragment Caching in CodeIgniter - El Forum - 01-27-2009 [eluser]Jelmer[/eluser] There's no fragment caching in CodeIgniter, there's 2 possible solutions for your problem though: - Database query caching: standard functionality, look in the User guide - MP_Cache : a class I wrote for a similar purpose, which would allow you to cache any part of your controller you like. With my library you'd rewrite the index function to something like: Code: function index() Fragment Caching in CodeIgniter - El Forum - 01-27-2009 [eluser]CrossMotion[/eluser] Sounds very cool, you did a nice job on this! Only I have a lot of page view counters showing how much times an item (in this case a widget) is viewed. I don't want to delete the cache every time one widget is viewed, but more like once per hour. So I need to delete the cache after a set amount of time. Do you have an idea how I could achieve this? Thx in advance! Dennis Fragment Caching in CodeIgniter - El Forum - 01-27-2009 [eluser]Jelmer[/eluser] I actually haven't added any cache-management options in the library. In my own implementation most of my cache files correspond to a certain query or set of queries and I delete them after any edit. To achieve what you want you could do it like this: Code: $data = $this->mp_cache->get('example'); Or you could create seperate caches for every widget. That would make your code a lot less readable, but also eliminate lots of duplicate cache and you could have seperate "re-caching" rules for every part of the page. Fragment Caching in CodeIgniter - El Forum - 03-31-2010 [eluser]Nir Gavish[/eluser] here's a fragment caching lib i wrote, if it's any help: http://codeigniter.com/wiki/Fragment_Caching_Library/ |