O'Reilly logo

CodeIgniter 2 Cookbook by Rob Foster

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using CodeIgniter caching

You can use CodeIgniter caching to cache (or temporarily store) practically anything. As an example of caching with CodeIgniter, we're going to cache an RSS feed. We could, of course, cache anything we wanted; however, caching an RSS feed is a good place to start. Working with RSS is quite simple and the recipe can easily be converted to cache feeds from other sources, such as a call to Twitter, for example.

How to do it...

We're going to create the /path/to/codeigniter/application/controllers/rss_cache.php file.

  1. Create the preceding file and add the following code to it:
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Rss_cache extends CI_Controller { function __construct() { parent::__construct(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required