Codeigniter Website Speed Optimization

0
16

Codeigniter website speed optimization

In this article, we are going to discuss Steps to follow the Codeigniter website optimizer. We are Web development, Software development, and Mobile application development company for many organizations that have created CMS, eCommerce, and Online Portal website development from us. We favor CodeIgniter, WordPress, Opencart as it’s fast and cost-effective. We are writing this case study to show you what steps were taken to improve website speed. These tips can be used for other platform Websites as well.

Performance Before Optimization

Check the Performance of the website using Google page speed or gtmetrix. you can find the website was languishing at the score.

Performance After Optimization

Check the Performance of the website using Google page speed or gtmetrix. you can find the website with a good score.

What information you will need:

In order to optimize the speed of a website, you will need to have access to the FTP, Cpanel credentials of the website.

Website speed testing tools

1. Google Pagespeed Insights
2. Pingdom website speed test
3. GTmetrix

Steps to increase Codeigniter website speed

Image optimization

Images need to be properly scaled and should reduce image size without affecting quality. it should not be resized using CSS.

Caching

Using Database cache we can tell the browser to use the previously downloaded content instead of downloading the contents from the server again and again. Also, you add following code in htacess

ExpiresActive On
ExpiresByType image/jpg “access plus 1 year”
ExpiresByType image/jpeg “access plus 1 year”
ExpiresByType image/gif “access plus 1 year”
ExpiresByType image/png “access plus 1 year”
ExpiresByType text/css “access plus 1 month”
ExpiresByType application/pdf “access plus 1 month”
ExpiresByType text/x-javascript “access plus 1 month”
ExpiresByType application/x-shockwave-flash “access plus 1 month”
ExpiresByType image/x-icon “access plus 1 year”
ExpiresDefault “access plus 2 days”

CSS & JS concatenation and minification

Combine and minify your CSS and JS contents. The benefit of combining contents is that the browser will make one request to the server instead of many. Also, you can add following code in htaccess

# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml

# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

Content compression

Content compression is an easy way to save bandwidth and speed up the Codeigniter website. Enable Gzip compression in Cpanel or In CodeIgniter, you can do it by simply setting the “compress_output” variable to true in config.php file.

$config[‘compress_output’] = TRUE;

You can also add following code in htaccess

mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

There are 3 ways to compress content. Can follow any one simplest way

Database queries optimization

Database cache can be enabled by The sample syntax is given below. Simple turn db->cache_on before a query and turn db->cache_off after the query returns results.