Loading...
2nd Feb 2011#

Simple steps to speed up Magento

After a recent Magento build for a client we were asked the age old problem “My site is running slow for visitors how can we speed this up?”

It’s actually not as complex as you might think to quickly speed up magento without having to do any massive code changes. Other than the obvious stuff like:

  • Host on a dedicated server (if your using a shared server)
  • Use a Content Delivery Network (CDN) to host your assets (Images / CSS / Javascript)
  • Use a heavyweight memory caching system like Memcache
  • Use CSS Sprites for all the smaller images across the site

There are some much simpler things to do. First off you are best off installing something like YSlow so you can actually measure / monitor your site performance rather than guessing. After you’ve installed YSlow you can run a page analysis and get a more detailed idea of what need to be improved.

Try doing the follow to improve the speed:

  1. Go to your Magento store admin, then go to: System > Cache Management and make sure you have everything enabled.
  2. Still in your store admin to go: System > Configuration > Developer (right at the bottom). Depending on what version of Magento you are using you should see 2 panels (Javascript Settings & CSS Settings) in these panels turn “Merge JavaScript Files” & “Merge CSS Files” to YES.

    This will merge all your header javascript files and css files into 1 respective file for each, thus reducing the amount of requests. This is especially good for the js files as Magento is built around the Zend PHP Framework so its bloated with the Prototype / Scriptaculous js libraries.

    Because you are merging files here, on the odd occasion this can cause some slight hiccups, so do give your site a once over after doing this

  3. Copy off your .htaccess file from root level of your server. You can do this via an FTP application. Once open, there are a few things you can uncomment to speed things up.

    Find the follow snippets of code and uncomment so they appear as they do in the boxes below. This will enable GZIP compression. You can read more about it here.

    ## enable resulting html compression
     
    php_flag zlib.output_compression on
    ## 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
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
     
    # 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
  4. Enable Header expires, so your browser will cache assets for a set period of time before flushing them. Items will automatically re-cache if you edit / clear your browser cache.
    ## Add default Expires header
    ## http://developer.yahoo.com/performance/rules.html#expires
     
    ExpiresActive On
    ExpiresDefault "access plus 1 month"
  5. Enable ETags, ETags allows caches to be more efficient, and saves bandwidth. Further reading can be found here.
    ## If running in cluster environment, uncomment this
    ## http://developer.yahoo.com/performance/rules.html#etags
     
    FileETag none

Just doing those 5 simple steps will greatly improve the speed of your Magento store. Be sure to make a backup of your .htaccess before making any changes (just in-case).

Written by Alex Murphy

Hey! My name is Alex and I'm a UK based web designer specialising in wordpress, front-end design and head designer here at GoMySites.

4 Comments

  1. Hi,
    very usefull post. I wonder if I can translate it into Slovenian, publish in my magento blog (personal blog about experiance with magento) and link it to your original post?
    tnx for answer

    • Yes sure feel free to add to your blog and link back.

  2. you wrote
    Use a heavyweight memory caching system like Memcache

    can you explain how it can be done?

Leave a Comment