Tuesday, 29 October 2013

Reduce the loading time of website

Following are IMP Rules to Reduce the loading time of website

1 - Make Fewer HTTP Requests (means Less Ajax Call)

2 - Use a Content Delivery Network (CDN)

3 - Add an Expires Header

4 - Gzip Components

5 - Put Stylesheets at the Top (CSS Files in head tag) 

6 - Put Scripts at the Bottom (Js files in footer)

7 - Avoid CSS Expressions (e.g 100/2)

8 - Make JavaScript and CSS External (Store the Css /Js in file and include them)

9 - Reduce DNS Lookups

10 - Minify JavaScript and css files (remove space, tab, indentation etc)

11 - Avoid Redirects (remove un-necessary redirect) 

12 - Remove Duplicate Scripts(Adding same javaScript / Css files two times)

13 - Configure ETags

14 - Make AJAX Cacheable

15 - Use Server side caching

16 - Use Client side caching

17 - Run time javaScript load must use cache
18- Add following code in .htaccess (Cache the JS/Image/Css & increase speed of website)

  ExpiresActive on
  ExpiresByType image/jpg "access 2 month"
  ExpiresByType image/gif "access 2 month"
  ExpiresByType image/jpeg "access 2 month"
  ExpiresByType image/png "access 2 month"
  ExpiresByType text/css "access 2 month"
  ExpiresByType application/x-javascript "access plus 2 month"
  ExpiresByType text/javascript "access plus 2 month"
  ExpiresByType application/javascript "access plus 2 month"
  ExpiresByType image/x-icon "access plus 12 month"
  ExpiresByType image/icon "access plus 12 month"
  ExpiresByType application/x-ico "access plus 12 month"
  ExpiresByType application/ico "access plus 12 month"

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.*

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript


You can check your website speed on http://gtmetrix.com

1 comment :

Anonymous said...

See Importants regarding Optimization.
1. You can use static assest servers for loading the static contents such images, css and js etc. For example If we put images in another server the images are loaded in parallel.
For Example:
Flipkart Domain URL: http://www.flipkart.com/
Flipkart CSS domain URL: http://server1.flipkart.com
Flipkart image domain URL: http://server2.flipkart.com
FlipKart ads loading URL: http://server3.flipkart.com
FlipKart logs are storing URL: http://server4.flipkart.com
FlipKart notification URL: http://server5.flipkart.com
In this way, flipkart is single site but using multiple domains to load the request in parallel.
2. you use use CDN (Content Delivery Network)
3. Use htacess carefully. Use L to avoid running of extra exectuion.
3. Do Caching in data on Server as well as on Browser cache.

Post a Comment