5 Simple steps to improve the performance of a CodeIgniter Site

5 Simple steps to improve the performance of a CodeIgniter applications. Speed Test, Identify error on the result, HTML output, Page Caching, and Gzip. 
1.   Speed Test:
First to test the speed of your website to using the tool like Pingdom. it is a free tool that helps to test your website performance from different locations.
2.   Identify error on the result:
This Tool displayed all the result and list of files how is taking more time to load and the user can see the result over there check the files and found the root cause of the error and resolve.
3.   HTML output:
if any white space exists in the HTML output, Hooks will perform this kind of job to remove white space. Go to "config" directory to open the "config.php" file and enable hooks:
$config['enable_hooks'] = TRUE;
Hooks provides the provision for extending the core of CodeIgniter, Hooks are defined in config path: application/config/hooks.php file. Each hook is specified as an array with this prototype:
Create a new hook:
$hook['display_override'] = array( 'class' => '', 'function' => 'requestCompress', 'filename' => 'compress.php', 'filepath' => 'hooks', 'params' => "" );
Create the file system/application/hooks/compress.php and add the following code:
function requestCompress() { $CI =& get_instance(); $buffer = $CI->output->get_output(); $search = array('/\>[^\S ]+/s', '/[^\S ]+\#s'); $replace = array('>','<','\\1',"//<![CDATA[\n".'\1'."\n//]]>"); $buffer = preg_replace($search, $replace, $buffer); $CI->output->set_output($buffer); $CI->output->_display(); }
4.   Cache functions:
To implement the caching on the function in the controllers. Add the below line of code and it will cached the HTML page. To make the Application/cache folder is writeable.
$this->output->cache(60); // Will expire in 60 minutes
5.   Enable Gzip Compression:
Enable the Gzip compression in your application/config/config.php file.
$config['compress_output'] = TRUE;
Note: Clear all the cached files from the cached directory: application/cache, make sure the cache directory is writeable.

Comments

Post a Comment

Popular posts from this blog

Bigbasket - Redirect to the Bigbasket Product Detail Page without choosing the location

Jquery Form Validation and Submission