Boost the speed of your Magento

Boost the speed of your Magento © http://www.sxc.hu/photo/1098526

One of the drawbacks of Magento is currently its speed if default configuration is used. There are certain ways of making it run faster.
Let’s start speeding up Magento!


First step, edit .htaccess file.

Enable Output Compression

This section will turn on the apache mod_deflate module, which compresses text, css, and javascript before it is sent to the browser. This results in a smaller download size. To enable, simply uncomment the appropriate lines so that it looks like the following:

############################################
## 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 application/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

Enable Expires Headers

Browsers use Expires headers to determine how long a page component can be cached. Static components, like images, should have far-future expires headers, but truthfully, all page components should have expires headers. To turn this feature on, just uncomment the appropriate line and add “ExpiresActive On” right above it. See below:

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires
 
    ExpiresActive On
    ExpiresDefault "access plus 1 year"

Keep in mind, if you use a far future Expires header you have to change the component’s filename whenever the component changes. More info http://developer.yahoo.com/performance/rules.html

Disable ETags

ETags are a way for browsers to validate cached components across subsequent visits. They can slow down a site served from a cluster if the cluster hasn’t implemented them properly. It is best to just turn them off as follows:

############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags
 
    FileETag none

Now, from Magento admin side make sure that you combine JS and CSS files.

  • Magento admin -> System Configuration -> Developer -> Under “Javascript Settings”, change “Merge Javascript Files” to YES.
  • Magento admin -> System Configuration -> Developer -> Under “CSS Settings”, change “Merge CSS Files” to YES

Clear the cache.

Use CDN if it is possible, please note combining CSS/JS when using CDN will cause CSS/JS to “break” until the CDN updates completely.

Enable Flat Catalog

Magento uses the EAV model to store customer and product data. This enables these objects to be incredibly extensible, but results in longer SQL queries and more reads. Enabling the Flat Catalog for Categories and Products merges product data into one table, thereby improving performance. Generally, all stores should enable Flat Catalog for Categories.

More information you can find following yslow user guide http://yslow.org/user-guide/, here you can find more tutorials and resources to follow.

Happy speeding 🙂

If you need any help, we can do a Technical Magento Audit for your site.

You made it all the way down here so you must have enjoyed this post! You may also like:

Build your 2017 Magento SEO strategy with these tips Ivona Namjesnik
Ivona Namjesnik, | 10

Build your 2017 Magento SEO strategy with these tips

Create unique coupon code in Magento Stanislav Mihic
Stanislav Mihic, | 19

Create unique coupon code in Magento

How to improve your web shop conversion rates Toni Anicic
Toni Anicic, | 7

How to improve your web shop conversion rates

151 comments

  1. # enable resulting html compression
    php_flag zlib.output_compression on
    also caused my site to throw a 500 error, but after taking it out the site is still 75% faster. Thanks for the great advice!

  2. Wow am I glad I found this page… Magento was loading so slow… had my doubts this would work, but yeppers, all my pages load at least twice as fast now… huge difference!

    Many thanks Tomislav!

  3. # enable resulting html compression
    php_flag zlib.output_compression on

    This line is throwing me a “500 Internal Server Error”

  4. Hi

    I have done the changes to my .htaccess file, at first I got a 500 error so I removed the last line that was not included in my original file

    # enable resulting html compression
    php_flag zlib.output_compression on

    However I did not notice any changes, if anything it slowed down my a few milliseconds.

    The only difference I notice is when I test my server @ http://www.whatsmyip.org/http_compression/ the results are:
    Original Size: 36.97 KB
    Gzipped Size: 6.58 KB
    Data Savings: 82.2%

    My average speed was and remains @ 1.9s.

    Google Site performance reports the following:
    On average, pages in your site take 2.3 seconds to load (updated on Nov 24, 2010). This is faster than 62% of sites.
    So I will keep on the lookout to see if they report a better performance (at the moment I’m in the Red!).

    My page speed score in Firebug was and remains @ 66/100.

    Should I keep these new changes?

    What else should I be looking at for increasing my site performance?

    Thanks everyone for this great post!

    Shragi

  5. Just one thing.. if you use

    SetOutputFilter DEFLATE

    instead of

    #AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

    this can cause problems with IE downloading downloadable products.

  6. On repeat page loads adding Etags made a difference for me apart from the compression settings above.
    You will have to have yslow off to notice the difference.

    try adding this line to the htaccess
    FileETag MTime Size

    The yslow and pagespeed grading also went up quite a bit.

    see the effect here http://shop.tapstore.com

  7. if you get 500 Internal Server error when enable deflate, you should enable apache headers mod.examples: debian , a2enmod headers, then /etc/init.d/apache2 restart. it ok…

    www.wowko.com

    is very fast and best 🙂

  8. Hi,

    I’ve just enabled the Gzip on the server (win 2003 standard with iis 6).

    Now, i have confirmed that the server as the Gzip activated with the test to a domain in the same server but when i try to test it on the Magento domain…it inst activated.

    Test Tool
    http://www.whatsmyip.org/http_compression/

    Domain in the same server
    http://directo.tr2k.com/login.aspx

    Domain with MAGENTO
    http://www.rockartstore.com/index.php/

    The .htaccess doest work on IIS so that’s not a solution…iv tried in the php.ini only seems to work on Apache.

    Any suggestions?

    Is there a place were i can enable it in the admin panel?

  9. I had the same problem. after following all the advices above , i came across this:

    # enable resulting html compression
    # For security reasons, mod_php is not used on this server. Use a php.ini file for php directives
    #php_flag zlib.output_compression on

    My host is bluehost.

    So in ~public_html/php.ini , change this line:

    zlib.output_compression = off
    to
    zlib.output_compression = on

    Now it is super fast.

    Thank you all

  10. Tomislav – thanks so much for this one! Big boost on all our sites. Thanks again.

    carlos – seems like your site may have some settings incorrect with your host? Super slow. Where is it hosted? Have you tweaked the php files per the many posts out there – really helped our sites. Good luck.

  11. some one please help me, its not working for me 🙁

    my site is loading in 5-7 sec

    i know i did the right change in .htaccess
    ############################################
    ## 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

    # enable resulting html compression
    php_flag zlib.output_compression on

    ############################################

  12. One thing missed and that a lot of people cry about on shared hosting is that HTTP compression is usually disabled permanently and the .htaccess enablement for HTTP Compression doesn’t work.
    This method doesn’t do your .css and .js files etc, but it does do every page in your store.
    Edit your index.php and add the following line at the very top on its own line.

    However do NOT use this method along with the .htaccess file method.

    Hope it helps those with Magento and 1and1 Internet etc.

    Rob.

  13. Here is my version used on production:

    AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript application/x-json application/x-httpd-php
    AddOutputFilter DEFLATE html xml css js php
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent

    Cheers! 😀

  14. Just halved my home page load speed with this… Awesome and thanks! I think it will translate into a reduced bounce rate too 🙂

  15. If the site is still in development will this affect the caching at all? Is this something you should do after launch or is it okay to do it in dev?
    Looking forward to trying this. And thank you!

  16. My site is also very slow, please help me to solve this issue. I am using godaddy as hosting server and this is mostly accessed in Holland.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.