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
    # 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
    ExpiresActive On
    ExpiresDefault "access plus 1 month"
  5. Disable ETags, removing the ETag reduces the size of the HTTP headers in both the response and subsequent requests. Further reading can be found here.
    ## If running in cluster environment, uncomment this
    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).