Showing posts with label Speed up Magento in Easy steps. Show all posts
Showing posts with label Speed up Magento in Easy steps. Show all posts

Tuesday, 24 December 2013

Effective steps to Improve Magento’s Performance


Effective steps to Improve Magento’s Performance

Step 1 : Enable Flat Categories and Products

In Magento admin, (top menu) System > Configuration, (left nav) Catalog > Catalog, (main page) Frontend.  Set “Use Flat Catalog Category” and “Use Flat Catalog Product” to “Yes“.

Attributes that apply to Categories and Products are stored in separate database tables depending on their dataypes. ‘Flattening’ will put all attributes in one table for Magento retrieve. This will have a positive impact on site speed especially if it has 1,000 or more products

Step 2 : Merge CSS and JS Files

In Magento admin, (top menu) System > Configuration, (left nav) Advanced > Developer, (main page) JavaScript Settings, CSS Settings. Set “Merge Javascript” Files and “Merge CSS” Files to “Yes

A Magento site can have many CSS and javascript files and there will be more that come with extensions and site customizations. Doing step #2, will combine all CSS and javascript into one file which will make each page load faster.

Step 3 : Enable Compilation

In Magento admin, (top menu) System > Tools > Compilation, click Enable. This will take all the active scripts in Magento’s core structure and bring them to the front for faster website speed.
If updates, code modifications, extension installations are needed, Compilation needs to be disabled first. If not, there will be errors

Step 4 : Caching Magento

When all other settings are in place and the site is ready to go live, go to System > Cache Management. Select all items, set the Action dropdown to “Enable” then hit Submit.

Step 5 : Image Optimizer

Image Optimizer will optimize your images (GIF, JPG, PNG) reduce their file size and speed up your site. Install below extension and optimize the images.

http://www.magentocommerce.com/magento-connect/image-optimizer.html

Step 6 : Image Cleaner

Image Cleaner will remove your unused images from site. This will reduce size on your hardisk. Install below extension and clean the images.

http://www.magentocommerce.com/magento-connect/image-clean.html

Step 7 : Edit .htaccess

Find the following lines in your Magento .htaccess file and replace them with the following code.

(You just have to uncomment the lines so it looks like the following)

############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip

# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don’t compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary

You need to uncomment the following as well:

############################################
## enable resulting html compression

php_flag zlib.output_compression on

Next we want to compress items such as CSS and javascript etc. Simply add the following lines of text directly into the htaccess file.


############################################
## compress text, html, javascript, css, xml:
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
# Or, compress certain file types by extension:
<files *.html>
SetOutputFilter DEFLATE
</files>


###########################################

Leverage Browser Caching and Expires Headers. This piece of code can make a huge difference and will reduce the number of HTTP request, which is a huge benefit for any returning visitors to your website. Simply add the following lines of text directly into the htaccess file.


<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year?
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 month?
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>

############################################

Step 8 : Google Page Speed Optimization extension

Install the given extension for render-blocking javascript. This extension put all the javascript exact before </body> tag.

https://github.com/mediarox/pagespeed

Step 9 : External Javascript after page load

Call all the external javascript after the page load like live chat, Google analytics code. Here i give you the small example:

<script type="text/javascript">
jQuery(window).bind("load", function() {

   // Your external javascript code here

});
</script>