thwd
thwd

Reputation: 24808

Codeigniter caching question

I’m fairly new to Codeigniter. I have been reading the user guide extensively but one question has remained open for me.

Consider this scenario:

An article page, completely static with only one little dynamic text displaying the number of views this article has got.

How could I cache such a page in order to serve it fast but still update the views counter?

Any answer will be greatly appreciated,

Tom

Upvotes: 0

Views: 523

Answers (1)

Ross
Ross

Reputation: 17967

I'm pretty sure CI's caching out of the box is for full pages only, so your views count would not be updated.

You could either specify a large cache time e.g. $this->output->cache(180); which would cache for 2 hours, and then update the count, or look in to partial caching. Here's one such library.

Upvotes: 3

Related Questions