##TotalCache library for CodeIgniter
###How to use library TotalCache for CodeIgniter ?
1- Copy the library (TotalCache.php) in application/libraries
2- To load it in CodeIgniter there are two possibilities: In application/config/autoload.php look for the following instruction $autoload['libraries']= array(); and add totalcache.
$autoload['libraries']= array('totalcache');
This way the library is loaded for the whole application. Load it directly in the class where you want to use it.
$this->load->library('totalcache');
3- In your controller, instead of calling $this->load->view('view_name',$data) to load view, use method viewAndCache of library TotalCache
$this->totalchache->viewAndCache('view_name', $data);
Example:
yourwebsite.com/controller/method/param
viewAndCache() method will create the file param.html which will contain the view generated by CodeIgniter. This file is located in the following directory tree created (if it doesn't exist) in the method: yourwebsite.com/static/controller/method
4- So that the cache file is served directly without invoking CodeIgniter, you need to add these instructions in your htaccess file at your website's root.
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/yourwebsite.com/static/$1 -f
RewriteRule ^(.*)$ static/$1 [L]
RewriteCond $1 !^(static|index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
#Htaccess editor for total cache
##How to use Htaccess editor
If you're not very confortable with htaccess instructions you can use the htaccess editor.
1- Upload it at your website's root.
2- Run it by entering this url in your browser: yourwebsite.com/htaccess_editor
Note: if you have this error message "SQLite 3 NOT supported", you need to activate sqlite3 extension in PHP. Look for these lines in php.ini and delete ; extension=php_sqlite3.dll && extension=phph_pdo_sqlite.dll
3- Enter a password so that nobody else can access the editor
4- Enter your own parameters
5- Delete tool from server when you don't need it anymore.
##Functions
Change site path
If you changed the name of your website or put your content in a sub-directory, you may need to change site path.
Change cache path
The default directory to save cache files is "static". You can modify it.
Note: this action will modify the code of library TotalCache. Make sure you added it in application/libraries.
Fully disable cache
Total cache is disabled for the whole application, it avoids you modifying your code
Partially disable cache
You can choose for which controller or method you want to disable cache without modifying your code.
Enable cache
Fully enables cache.