views:

115

answers:

2

I have a couple of things I'm working on, namely a page that issues five or six cURL requests and processing content on them.

I'm working with CodeIgniter on a LAMP stack but am open to other options. Naturally I would prefer to not rewrite the application.

I would like to know if there are any ready-made / easily learned caching methods. Primarily I'd like to check if the page has changed since I last scrapped it. If it has, redownload and present. If it hasn't, serve up a cached copy.

A: 

Why don't you use CodeIgniter's builtin cache library?

Yorick Peterse
Because that's now what I want. I want to check if a page has changed since the last scrape and not request it if it has.
Josh K
+1  A: 

Have a go with my Cache library.

Combine that with my cURL library and you'd have some very simple syntax.

// un-cached
$this->load->library('curl');
echo $this->curl->simple_get('http://example.com/');

// cached
$this->load->library('cache');
echo $this->cache->library('curl', 'simple_get', array('http://example.com/'), 120);

That'll cache your page request for two minutes.

Phil Sturgeon