views:

2076

answers:

1

I have read the documentation for the CI Caching but still don't understand much about it. What exactly does it do, and what is the use of caching a dynamic website?

+5  A: 

From wikipedia:

... a cache is a collection of data duplicating original values stored elsewhere or computed earlier, where the original data is expensive to fetch or to compute, compared to the cost of reading the cache.

A cache allows you to trade relatively expensive operations (complicated/multiple queries for example) for less expensive ones (reading a file / from memory). In dynamic websites a cache is often used just for that purpose (database IO to file IO).

Caching is useful when specific data is read often but updated seldom, and can be shared between many requests. Blog posts are an excellent example of this (created once, edited several times, read many times).

Eran Galperin