Boost the speed of your Magento

Boost the speed of your Magento ©

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

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
    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, 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


  1. Hi,
    If it’s not working for you, just place the code top of the index.php
    if (substr_count($_SERVER[‘HTTP_ACCEPT_ENCODING’], “gzip”))

  2. I hate to ask a stupid question (I’m not an apache genius). I’ve actually wondered about this for a long time and this seems like as good a place to ask as any.

    # 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

    Should both of those lines be uncommented? Isn’t it one or the other; either all content OR filtered content?

    Just wondering.

  3. Just proves that some good advice goes a long way. Still rocking these tips in 2015! Big big respect for Inchoo from

    Thanks t0 these tips, got a YSlow score bump to 85+ from 35!!
    If it helps anybody, KeepAlive settings really speeds up Magento sites further, but be sure to do your research.

  4. I just used the above code for my magento estore. My developers worked on the above code to
    implement it in website. After implementing I felt same like as the loading time at initial stage and
    later it has improved.

    Apart from this, I’ve also followed the below techniques from the following post:
    From Server Side:

    MySQL Database Tuning
    Deploying Varnish
    Nginx server cache
    Load Balancing Implementation

    From Application Side Optimization

    Reducing HTTP requests
    Full Page Cache access
    Ajax Loading
    Content Delivery Network

    Now the loading time optimization improved much better with the results.

  5. In order to speed up the Magento Admin Panel, you need to:
    1. Set up Varnish cache
    2. Tune up the database
    3. Clean up the cache
    4. Delete unused extensions
    5. Delete out-of-sale products
    6. Reindex your products

    In order to speed up Magento Frontend performance, you need to:
    1. Compress the output
    2. Use Expires Headers
    3. Merge CSS files with JS files
    4. Use Memcached
    5. Use Parallel Downloads

    For more information, download the e-book, 11 Definite Ways To Speed Up Magento Websites, now.

  6. Tips that only improve performance for very busy servers (100+ pageviews/min):
    Move all htaccess content to apache conf files (require some knowledge about apache).
    Disable htaccess files.
    Disable magento log debug or enable logrotate.
    Enable magento log cleaning to 1 week or down.
    Be happy.

  7. Thanks Dude. It really works, I followed all steps and it makes my site really fast. I checked on Google Pagespeed tool and Manually check the speed and found it really fast. But Still on 75/100 on Desktop and 60/100 on Phone. Please tell me how I can make it bit fast on Phone as well.

    Thanks in Advance.

  8. My htaccess file doesn’t have any of the code you mentioned above.What it has is given below.If there is any suggestion for me then please let me know.My website is running very slow..

    #Gzip – compress text, html, javascript, css, xml

    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

    #End Gzip

    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_keep_workfiles No
    mod_gzip_can_negotiate Yes
    mod_gzip_add_header_count Yes
    mod_gzip_send_vary Yes
    mod_gzip_command_version ‘/mod_gzip_status’
    mod_gzip_min_http 1000
    mod_gzip_minimum_file_size 300
    mod_gzip_maximum_file_size 512000
    mod_gzip_maximum_inmem_size 60000
    mod_gzip_handle_methods GET POST
    mod_gzip_temp_dir /tmp
    mod_gzip_item_include file \.html$
    mod_gzip_item_include file \.php$
    mod_gzip_item_include file \.pl$
    mod_gzip_item_include file \.rb$
    mod_gzip_item_include file \.py$
    mod_gzip_item_include file \.cgi$
    mod_gzip_item_include file \.css$
    mod_gzip_item_include file \.js$
    mod_gzip_item_include mime ^application/javascript$
    mod_gzip_item_include mime ^application/x-javascript$
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_include mime ^httpd/unix-directory$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include handler ^server-status$
    mod_gzip_item_include handler ^server-info$
    mod_gzip_item_include handler ^application/x-httpd-php
    mod_gzip_item_exclude mime ^image/.*

    # Enable expirations
    ExpiresActive On
    # Default directive
    ExpiresDefault “access plus 1 month”
    # My favicon
    ExpiresByType image/x-icon “access plus 1 year”
    # Images
    ExpiresByType image/gif “access plus 1 month”
    ExpiresByType image/png “access plus 1 month”
    ExpiresByType image/jpg “access plus 1 month”
    ExpiresByType image/jpeg “access plus 1 month”
    # CSS
    ExpiresByType text/css “access 1 month”
    # Javascript
    ExpiresByType application/javascript “access plus 1 year”

    Header unset Pragma
    FileETag None
    Header unset ETag

    # cache images/pdf docs for 10 days

    Header set Cache-Control “max-age=864000, public, must-revalidate”
    Header unset Last-Modified

    # cache html/htm/xml/txt diles for 2 days

    Header set Cache-Control “max-age=7200, must-revalidate”

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    suPHP_ConfigPath /php.ini

    order allow,deny
    deny from all


    ExpiresActive On
    ExpiresByType image/jpg “access plus 1 year”
    ExpiresByType image/jpeg “access plus 1 year”
    ExpiresByType image/gif “access plus 1 year”
    ExpiresByType image/png “access plus 1 year”
    ExpiresByType text/css “access plus 1 month”
    ExpiresByType application/pdf “access plus 1 month”
    ExpiresByType text/x-javascript “access plus 1 month”
    ExpiresByType application/x-shockwave-flash “access plus 1 month”
    ExpiresByType image/x-icon “access plus 1 year”
    ExpiresDefault “access plus 2 days”


    # Google Analytics Integration – Added by cPanel.

    AddOutputFilterByType SUBSTITUTE text/html
    Substitute “s|()?||i”

    # END Google Analytics Integration

    ## X-UA-Compatible: IE=8
    Header set X-UA-Compatible “IE=EmulateIE8”

    # BEGIN Expire headers

    ExpiresActive On
    ExpiresDefault “access plus 1 seconds”
    ExpiresByType image/x-icon “access plus 2592000 seconds”
    ExpiresByType image/jpeg “access plus 2592000 seconds”
    ExpiresByType image/png “access plus 2592000 seconds”
    ExpiresByType image/gif “access plus 2592000 seconds”
    ExpiresByType application/x-shockwave-flash “access plus 2592000 seconds”
    ExpiresByType text/css “access plus 604800 seconds”
    ExpiresByType text/javascript “access plus 216000 seconds”
    ExpiresByType application/javascript “access plus 216000 seconds”
    ExpiresByType application/x-javascript “access plus 216000 seconds”
    ExpiresByType text/html “access plus 600 seconds”
    ExpiresByType application/xhtml+xml “access plus 600 seconds”

    # END Expire headers

    # BEGIN Cache-Control Headers

    Header set Cache-Control “max-age=2592000, public”

    Header set Cache-Control “max-age=604800, public”

    Header set Cache-Control “max-age=216000, private”

    Header set Cache-Control “max-age=600, private, must-revalidate”

    # END Cache-Control Headers

    # BEGIN Compress text files

    SetOutputFilter DEFLATE

    # END Compress text files

  9. Dude. you rule. This totally worked. Through a 500 at first but then cleared cache and it worked like a charm.. Thanks!!!!

  10. I’m running CE 1.7 I too had to comment out
    “php_flag zlib.output_compression on” because of 500 server error, that being said, great improvement!

  11. i have tried everything to make it work , however its giving me 500 error , if enabled the last line

    I dont have php.ini file on my server , so no way to change that

    Any help would be greatly appreciated

  12. What I found out trying this code was that I had some bad requests in the HTML HEAD (head.phtml).. I had placed some css and js links in there and Magento didn’t like it. I’d already linked to the same files in the local.xml so the site was working but very slowly. Tested the site at saw all the warnings against the rogue js and css links.. removed the links from head.phtml and the site was instantly transformed. I also noticed that the scriptaculous js files were taking some time to load.. I’m using jquery for sliders etc so not sure I need them. Does anyone know if you can remove the scriptaculous files or do they do something elsewhere?

  13. Its the best method to speed up the magento. For those this method doesn’t work, try enabling zlib compression in php.ini

    Set “zlib.output_compression = on” in php.ini

  14. awesome……………it works but depend on your server…
    i have tried on 2 server…old server & latest tech
    server… only working on latest tech server … cheerss…

  15. Kate, yes, you just need to uncomment (remove the # before the line) of the lines in the .htaccess of your file.

    It seems for me also that it’s faster also !

  16. I copied the above code and pasted it into my htaccess but I don’t see any difference in speed and Google is still asking for compression to be turned on. Any help would be fantastic – thanks!

  17. I’m sort of confused about what code I am replacing or adding? Do I find the lines of code you marked # and replace them with the lines of code beneath each line marked #? Sorry! And thank you!

  18. Thank you so much for this post.
    I have applies it on ver and it works like charm.
    Is there more tricks to speed it further? 🙂
    I just like Formula 1

  19. Major props to you bro. this was an excellent solution. we have 50+ sites and they were all running super super slow, now they’re lighting fast!! thanks again

  20. Server error 500 solved.

    I had as well this error and found that I needed to enable mod_headers. On Ubuntu a2enmod headers
    Hope this helps somebody.

  21. this is throwing the same 500 server error for me as well. I removed the last line starting with “php” and the site is back up but not sure if speed is up or down.

    Any one have any suggestions? My magento version is

  22. I need to make my magento site faster. There fore I applied your setting in htaccess but

    # enable resulting html compression
    php_flag zlib.output_compression on

    particular code giving 500 error. Once removing the code the site runs but not faster.

    How can I add this compression code and if I need to set anything in server, then how can I do that one. Please guide as your help will be entirely grateful for me.

  23. Incredible !! Has solved my problem. On a clean mgto instalation admin panel go so so very very slow, and some times don’t answer.

    I have folow this sugestion, and now, is excelet fast.

    Thanks very very much for an excelent solution. 😉


  24. TinyBrick’s LightSpeed module has some pretty impressive results when it comes to speeding up Magento. The price might be a little steep, but the performance increases I’ve seen are totally worth it.

    You can see it here: [a href=””]TinyBrick’s Magento LightSpeed Module[/a]

  25. I’ve seen a similar saving with my magento website. Thanks so much for sharing! This is a MUST if you run on a shared hosting package!

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.