Magento Performance and Speed Optimization Tips

Topics focus on Web Developments, Programming, Database, Digital Marketing Tutorials, Code Snippets, SEO, Social Media Marketing and Inspirational articles.

Magento Performance and Speed Optimization Tips

Magento Performance and Speed Optimization Tips

Let’s begin with the basics of Magento Performance and Speed Optimization Tips. Tips here are mainly just configuration tweaks. They are easy to implement and test. And if you don’t like them you can easily revert all your changes. Make sure you restart your service after the configuration change.

We will cover 5 easy points in this article, additional methods will be explained in the advanced article:

  • Save the sessions in database
  • Enable Magento Cache
  • MySQL Query Cache
  • Enable file compression in .htaccess
  • Clean up the template

Save the sessions in database

It’s better to save the sessions in the database rather than the file system; this allows much, much faster access of all sessions. Magento supports this very well.

Expected effect: For small stores, the improvement may be relatively small, but if you have a sizable store with concentrated traffic, the effect is quite appreciable.

You can choose to save sessions to database during your Magento installation.

Or you can edit the app/etc/local.xml:

1
    <session_save><![CDATA[db]]></session_save>

Enable Magento Cache

This is almost trivial, but very important. The fact is, in many cases, the cache might be disable manually by developer, so that any code update will take effect immediately. But unfortunately, the cache may stay disabled when eventually the Magento store is deployed on a live server.

Expected effect: Significant in all cases. This is a must.

In the admin panel, under System > Cache Management, just make sure that all caches are enabled.

In fact, system cache is the major target for Magento performance improvement. A very effective way is to use RAM disk. This is beyond the scope of this article, and we will talk about the details in Speed up your Magento site (Advanced).

MySQL Query Cache

MySQL offers a very handy feature: ‘Query Cache’. This is indeed a good solution to handle the Magento EAV data model, which tends to produce ‘heavy’ queries.

Expected effect: This one is sensitive to large EAV objects in your store, especially ‘products’. For stores with less than 1,000 products, the effect would be hardly appreciable. For stores in the 1,000~10,000 range, this is optional, a cache of size 16M~32M can bring some improvements. But for stores with 10,000+ products, this is almost a must.

Modify my.conf as the following (you will need root access) :

1
2
    query_cache_type=1
    query_cache_size=64M

You need to restart your MySQL server after done.

Enable file compression in .htaccess

A large portion of Magento pages are simply text like html, JavaScript and CSS. And text contents are perfect targets for compression; they really have excellent compression ratios. Magento already provides an option to do this, we just need to enable it.

Expected effect: The result can be dramatic on stores running on shared hosting. If you already have a very good dedicated server, the effect may not be obvious.

By default, this option is commented out in Magento .htaccess file. Just uncomment this part so it looks like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    ############################################
    ## 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

Clean up your template

It’s always a good idea to move any JavaScript and CSS within you template .phtml file into an external file, so that they can be properly cached.

Especially you should clean your default core templates. This is something you can do in line with search engine optimization of the header templates to save time. By default Magento is loading 10+ JavaScript files and 6 CSS files. We can ‘minify’ these files by compressing them into s single file.
However this is more than just a configuration change, and We will talk about the details in Magento Speed up (Advanced).

Add comment


 

Pin It on Pinterest

Share This