Speed up Magento Performance

Below is the list of ways to speed up your Magento site. :)

Hosting Environment

Ø  Host only those files that you have to use
Ø  Go to MySql Admin and select all the tables and repair and then optimize them
Ø  Use PHP Accelerator like APC, Zend optimizer , Xcache
     APC – http://pecl.php.net/package/APC
     Xcache – http://xcache.lighttpd.net/
     Note: By default magento stores its cache into file system
    You have to add following code into local.xml
After saved your changes, remember to refresh cache.

Ø  Enable GZIP/DEFLATE compression in .htaccess.

  • Go on this link and enter your magento site address. If it come back with green tick and say http://yoursitename.com is gzipped then skip next step. If not then go on next step.
  • Find following lines in your .htaccess file and replace them with following code
<IfModule mod_deflate.c> ############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter on all content
SetOutputFilter DEFLATE
# Insert filter on selected content types only
# 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
Ø  Use Apache mod_config and be sure to set how long these files should cached.
Example for Apache virtual host config:
# Turn on Expires and set default to 0 ExpiresActive On
ExpiresDefault A0
# Set up caching on media files for 1 year (forever?)
ExpiresDefault A29030400
Header append Cache-Control “public”
# Set up caching on media files for 2 weeks
ExpiresDefault A1209600
Header append Cache-Control “public”
# Set up 1 week caching on commonly updated files
ExpiresDefault A604800
Header append Cache-Control “proxy-revalidate”
# Force no caching for dynamic files
ExpiresActive Off
Header set Cache-Control “private, no-cache, no-store, proxy-revalidate, no-transform”
Header set Pragma “no-cache”

Ø  Enabled Apache KeepAlives. Make sure your Apache configuration has KeepAlives enabled.

  • KeepAlives are a trick where multiple HTTP requests can be funneled through a single TCP connection. The setup of each TCP connection incurs additional time; this can significantly reduce the time it takes to download all the files (HTML, JavaScript, images) for a website.
For more:  http://httpd.apache.org/docs/2.2/mod/core.html#keepalive
Ø  Set ‘php_value memory_limit 128M’ in your PHP configuration or add it to your .htaccess file to ensure you don’t run out of memory.

php_value memory_limit 128M

Ø  Modify the configuration for your MySQL server to take better advantage of your server’s  RAM
  • Most Linux distributions provide a conservative MySQL package out of the box to ensure it will run on a wide array of hardware configurations. If you have ample RAM (e.g., 1 GB or more), then you may want to try tweaking the configuration. An example my.cnf is below, though you will want to consult the MySQL documentation for a complete list of configuration directives and recommended settings.
key_buffer = 512M
max_allowed_packet = 64M
table_cache = 512
sort_buffer_size = 4m
read_buffer_size = 4m
read_rnd_buffer_size = 2m
myisam_sort_buffer_size = 64m
tmp_table_size = 128m
query_cache_size = 96m
query_cache_type = 1
thread_cache_size = 8
max_connections = 400
wait_timeout = 300
Ø  Speed up your  Cache file:
Magento makes extensive use of file-based storage for caching and session storage. The slowest component in a server is the hard drive, so if you use a memory-based file system such as tmpfs, you can save all those extra disk IO cycles by storing these temporary files in memory instead of storing them on your slow hard drive.
Magento install is at /var/www/yourdomain.com/ so your cache and session directories are /var/www/yourdomain.com/var/cache/ and /var/www/yourdomain.com/var/session/For cache we will allocate a max of 256MB RAM and for sessions 64MB RAM. It is important to give access to everyone
Please note, your tmpfs is temporary in sense nothing will be created on your hard drive. If you reboot, everything in tmpfs will be lost.
Mount a tmpfs cache
mount  tmpfs /var/www/html/yourdomain.com/var/cache -t tmpfs -o size=64m mount  tmpfs /var/www/html/yourdomain.com/var/session -t tmpfs -o size=64m
For more space change 64m by any value (take care of your system RAM)
Remember to restart apache.
Other Best way is:
Another option for the sessions is to save them in your database. Magento supports this very well and it is one small step to make this work. Just edit app/etc/local.xml and set
It will then save all sessions in the database which is a much quicker access than the filesystem. When you use a cluster enviroment you had to use this option.
Ø Memcache your session
Follow link: – http://www.magentocommerce.com/boards/viewthread/9037/

Magento Configuration:
Ø  Uninstall the extension that you don’t actually use
Ø  Enable all Magento Cache :- System/Cache Management
Ø  Combine “Java script” and “CSS” files :
System/ configuration -> Advanced -> Developer

“Java script settings” and “CSS settings”.
You can also do this by using this extension: Fooman Speedster extension
Ø  Use Magneto’s Compilation feature. It’s reported to give you a 25%-50% performance boost: System > Tools > Compilation.
Ø  Don’t use layered navigation if you don’t really need it, its resource intensive.
Ø  Use the correct session storage. The choice is either database or files and the best setup depends on your system setup so be sure to test which one works best for you
Ø Disable the Magento log: System -> Configuration -> Advanced -> Developer -> Log Settings (default is disabled)
Ø  Set only those attribute frontend properties to ‘Yes’ that you’re actually going to use. Set all other to ‘No’. Don’t uses in quick search, advanced search compare, etc…
Catalog -> Attributes -> Manage Attributes -> Frontend Properties

Do me fever,
Do you have any tips? Post them in the comments and I’ll add them to the list!


Inchoo | Yireo.com | Magentocommerce forum thread about these tips | Methods and Best Practices for High Performance eCommerce
Regards :)
Gaurav Mehta


  1. Hello Mr. Mehta

    Such a great post...


  2. Great post... currently implementing on our website www.harrisonlighting.co.uk

    Many thanks

  3. The blog was absolutely fantastic! Lot of great information which can be helpful in some or the other way. Keep updating the blog, looking forward for more contents...Great job, keep it up..
    magento development company in bangalore 

  4. This is a great post. I like this topic.This site has lots of advantage. It helps me in many ways.Thanks for posting this again.
    magento development company in bangalore 

  5. Great blog created by you. I read your blog, its best and useful information. You have done a great work. Super blogging and keep it up.php jobs in hyderabad.

  6. • Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingAzure Online course Hyderabad


Post a Comment

Popular posts from this blog

Magento Reindexing problem - take too long time

Magento Navigation menu of CMS pages

Dont want to merge old carts items with current quote