Optimising Magento for High Google Page Speed Rank

30
Nov
Google

Magento is one of the best E-commerce platforms available. However if it’s not optimised correctly it can run slowly and have a negative impact on your sites performance and your customers browsing experience. This is a little tutorial that will show you how to optimise Magento and get the best possible page speed rank from Google.

  1. MySQL

    MySQL plays a big part in Magento, in fact without it the store wouldn’t run at all. However if it isn’t optimised correctly it may not run in the most efficient way.
    In your /etc/my.cnf file add these values (You should see a difference)

    key_buffer = 384M
    max_allowed_packet = 1M
    table_cache = 1024
    sort_buffer_size = 2M
    read_buffer_size = 2M
    read_rnd_buffer_size = 8M
    myisam_sort_buffer_size = 64M
    thread_cache_size = 16
    query_cache_type = 1
    query_cache_size = 48M
    log_slow_queries=/var/log/mysqld.slowquery.log
    max_connections=500
    wait_timeout=120
    tmp_table_size = 64M
    max_heap_table_size = 64M
    innodb_buffer_pool_size = 2048M
    innodb_additional_mem_pool_size = 20M

  2. Caching

    Make sure that your Magento store has caching turned on, Caching is such a fundamental part of Magento and with it disabled your store will take ages for pages to load. It may also be worth looking at APC Cache or Memcached.

  3. Compression

    This will help your Google page speed ranks high as well as page load times down. In your HTTP configuration file make sure you load modules, headers and expiries.
    Then add these lines:

    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
    ExpiresActive On
    ExpiresDefault “access plus 10 days”
    DeflateCompressionLevel 9

    Most importantly the ExpiresDefault basically tells the browser that once it loads this image then it doesn’t need to load it for another 10 days. And the AddOutputFilterByType tells the browser that it these images are compressed.

  4. NGINX vs Apache Webservers

    Apache is fantastic, its powerful and its secure however its sheer flexibility shoots itself in the foot because it’s layer upon layer of modules. NGINX is a relatively new webserver written by Igor Sysoev, It currently powers over 40,000,000 domains on the Internet, and over 20% of the top 1000 busiest websites around the world, including Facebook, Zappos, Groupon, LivingSocial, Hulu, TechCrunch, Dropbox and WordPress. Even Varien have moved the demo Magento store onto NGINX. Its written in such a clever way it has immense power but little need for high powered hardware, simply because Nginx doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load.

There are lots of other little tips and tweaks you can do to help the speed of your Magento site, but if you implement the ones in this post you should be almost there. If you want to find out more about our Magento hosting solutions please contact us.