# Cache

The views use by default a cache system.

When loading a view, a file titled tmp_{fileDirectory}.php will be created in the cache folder if it doesn't exists already.

So the view will be loader from that file and any change made to the original file will not be displayed until the cache file expires or is deleted manually.

You can perfectly refresh the cache deleting the cache folder content.

If you want to force a view to don't use the cache system, you can pass a false value to the loader view method as the third parameter.

$this->load->view('home', $data, false);

This will force that view to don't use the cache system, keep in mind that the loading time could increase due to this.

The default life time for a cache file is One week, it is specified as a constant in the system/Core/Cache.php file, you can change it if you want.

Methods

Create folder

You can manually create the cache folder if it doesn't exists, using the mkdir method.

Cache::mkdir();

Has

If you want to know if a cache file already exists for a view you can use the has method.

Cache::has('home');

That will return true if the home cache file exists, false otherwise.

Delete

You can delete a cache file using the delete method.

Cache::delete('home');

That will delete the home cache file.

Clear

You can delete all the cache using the clear method.

Cache::clear();

That will delete all the cache files.

Expired

You can see if a cache has expired using the expired method.

Cache::expired('home');

This will return true if the home cache file has expired.

Get Filename

Returns the cache format name applied over the specified file name.

Cache::getFilename('home');
//Will return tmp_home.php