开发者

Content cacheing with PHP and CodeIgniter

开发者 https://www.devze.com 2022-12-26 14:12 出处:网络
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 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 applicat开发者_JS百科ion.

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消