[eluser]mddd[/eluser]
The basic cache function of CodeIgniter only caches the output of the whole page. This will not work for you if there is any information on the page that is different for one user or another.
I wrote some code for myself that looks at the variables in a certain view and caches that view, while keeping it separate from the same view when it has other data. Basically, it works like this:
Code:
$id = $some_id; // for instance, a user id when loading a user's profile
// now check if this view was already cached for this id
// build the filename for this cachefile. it is "nameOfView.idOfView"
$cachename = CACHE_FOLDER . 'profile.' . $id;
if (file_exists($cachename))
{
// get the output from the cached file
$output = file_get_contents($cachename);
}
else
{
// get the data through a model
$data = this->user_model->get_user_profile($id);
// load the view
$output = $this->load->view('profile', $data, true);
// save the contents to a file for next time
file_put_contents($cachename, $output);
}
Note: in reality you should also check if the file is not too old, and if the information is somehow changed (in this example: if a user changes their profile), you should delete the cachefile so it is loaded correctly with the new information the next time.
Also, you should look into existing libraries that do this kind of stuff. I'm sure it has been done before.