One of the main purposes of caching is to save resources and not do things like hit your database every request. In light of this, I'm confused by what all Codeigniter does in a controller when it encounters a cache()
statement.
For example:
$this->output->cache(5);
$data=$this->main_model->get_data_from_database();
$this->load->view("main/index", $data);
I realize that the cached main/index
html file will show for the next 5 minutes, but during these 5 minutes will the controller still execute the get_data_from_database()
step? Or will it just skip it?
Note: the Codeigniter documentation says you can put the cache()
statement anywhere in the controller function, which confuses me even more about whats getting executed.