How to optimize the site

Web page optimisation is the process of systematically improving the performance of your website to meet your business objectives. Website optimization is important because it helps your website visitors be more successful with their visits to your website.


Every visitor comes to your site hoping to answer a question, find a solution to their problem, or complete a task of one kind or another. When you optimize your website you are making it easier for your site visitors to accomplish those tasks.


Major things you need to take into the considerations like, home page faster load, no broken links, lightweight pages, standard way of calling third party links, immediate response when any action is taken, keeping the codes more secure and many more.



Kindly use the below tips to make your site more stronger:


1. Gzip Compression: Gzip Compression technique is useful for compressing your webpages and style sheets before sending them over to the browser. This drastically reduces transfer time since the files are much smaller.


Gzip will work in such a manner that it locates similar strings within a text file and replaces those strings temporarily to make the overall file size smaller. To make this gzip to be enable kindly add the below piece of code on your .htaccess file.

<IfModule mod_deflate.c>

 # 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

</IfModule>


2. Leverage browser caching: Whenever browser loads a webpage many number of times it has to download all the web files to properly display the page. This includes all the HTML, CSS, JavaScript and images which may be called internally or externally.


So Browser caching can help by storing some of these files locally in the user's browser. Moreover the first visit from any user to your site will take the same time to load, however when that user revisits your website, refreshes the page, or even moves to other pages of your site, they already have some of the files they need locally.


Kindly add these codes on your htaccess file which will set caching parameters to tell the browser what types of files to cache.


## EXPIRES CACHING ##

<IfModule mod_expires.c>

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"

</IfModule>

## EXPIRES CACHING ##


3. Keep Alive: It is a simple concept referred as one method to allow the same tcp connection for HTTP conversation instead of opening a new one with each new request.


Moreover it is a valid communication between the web server and the web browser that says "you can grab more than just one file at a time".


Use the below code under your htaccess files to make it alive:


<ifModule mod_headers.c>

Header set Connection keep-alive

</ifModule>


4. Mysql Tuner: Database tuning is an very important thing if you are having larger dynamic sites and your actions are completely depending on mysql database then you should install mysql tunner to your server.


MySQL Tuner is a  small script written in Perl which allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. It will check the current configured variables and status data and present a brief format along with some basic performance suggestions.

yum install mysqltuner

mysqltuner



Note: You need to login to your vps server to install mysql-tuner.