Boost the speed of your Magento
32 Comments 30th JUN 2008 | Posted by Tomislav Bilic in 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. The best one is to enable GZip compression by changing .htaccess file a little. You just need to uncomment part of the code. In my case, the speed increase was exactly 235%.
Find the following lines in your Magento .htaccess file and replace them with the following code.
############################################
## 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
# enable resulting html compression
php_flag zlib.output_compression on

















August 1st, 2008 at 14:53
Wow, amazing how much this changes. It’s actually pretty fast now.
Thanks for the advice!
Cheerz, Casper.
August 4th, 2008 at 19:25
You can also play with DeflateBufferSize and DeflateCompressionLevel settings. But don’t make DeflateCompressionLevel too high, though
August 12th, 2008 at 7:41
Thanks Vladimir,
Can you please present the examples of such usage?
August 12th, 2008 at 14:04
I did it this way (this is a part of <VirtualHost> declaration):
<IfModule mod_deflate.c>
DeflateBufferSize 32768
DeflateCompressionLevel 5
<Location />
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|tiff)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
</Location>
</IfModule>
August 12th, 2008 at 14:51
Thank you
August 22nd, 2008 at 15:34
Hi!
is this valid for *any* webhosting?
thanks.
-andres
August 25th, 2008 at 21:11
Hi Andrés,
Most of the things don’t always work on all hostings. For example, I’m sure Vladimir’s suggestion is ok, but that doesn’t work on mine.
September 12th, 2008 at 22:12
Wow this works really well, thanks for the advice!
September 18th, 2008 at 14:19
Amazing! Thank you!
September 22nd, 2008 at 5:08
my htaccess file already looks like that. i just d-loaded two days ago. am i missing something?
September 28th, 2008 at 3:31
When I try this on Mosso clustered hosting I get a 500 Internal Server error
September 29th, 2008 at 4:06
i just tried using magento, but it’s way slow. where can i get the .htaccess file? the one i got off my server only has 3 lines in it about “order deny, allow Deny from all”
this isn’t the right file is it?
September 29th, 2008 at 21:46
Thanks, fortunately it did help making magento run three times faster
October 26th, 2008 at 10:50
Made a huge difference unreal
October 28th, 2008 at 20:16
What a difference far faster, i’m not 100% sure but this htaccess setup should work on any website!
AC-k3v, yes Magento v 1.1.6 has the coding in the htacess, however it is in a comment block and needs editing out.
November 7th, 2008 at 12:39
It depend if Apache is 1.3 or 2.0. I have Apache 1.3 and i have to use mod_gzip setting in htaccess:
mod_gzip_on Yes
November 12th, 2008 at 20:06
Someone posted a comment to my post (that refers to your solution) mentioning there’s another line of code that needs to be uncommented otherwise I don’t think these changes work.
############################################
## enable resulting html compression
php_flag zlib.output_compression on
December 16th, 2008 at 15:11
Thanks man! Works Great!
December 16th, 2008 at 22:15
Fantastic! – Good call on uncommenting the zlib flag, XPC.
December 18th, 2008 at 23:16
Id didn’t work for me, should it start working as soon as you modify the .htaccess? Did I miss another step?
December 21st, 2008 at 7:20
thanks so much!!!!! it truly works much more faster than before!
December 21st, 2008 at 12:04
@Aldo
Yes, it should start when you modify .htaccess file. If it doesn’t work, there could be several reasons, probably related to server configuration. Also, take a look at the comment from XPC Design to see if it helps.
Many thanks.
January 28th, 2009 at 18:40
thanks for the info Bilic…
is this compatible with magento-1.2.0.3, also?
January 28th, 2009 at 21:28
GREAT JOB
……yes it works with 1.2.0.3
February 7th, 2009 at 4:15
Can someone cut and paste their htaccess file? Mine keeps giving me a 500 Internal Server Error when I add Vladimr’s suggestions
February 10th, 2009 at 14:10
@Mark:
Commenting this out solved the 500 here:
# Make sure proxies don’t deliver the wrong content
# Header append Vary User-Agent env=!dont-vary
April 7th, 2009 at 3:13
Nice maybe I’ll start my own “fast” $20-$50 / month web hosting company with this, it improved my speed by at least 10,000% on a $3 / month web host….no joke
April 7th, 2009 at 15:06
I did as the above instruction but no success. the site’s speed seems not changed anymore. I use magento 1.3.0
April 8th, 2009 at 14:54
Great tip. Thanks!
June 2nd, 2009 at 21:18
didn’t help my site out.
Magento 1.3.2.1
hosted at Crucial Webhosting on a split-shared container.
June 20th, 2009 at 16:50
Just did this on my dedicated linux vm @ GoDaddy and my time to first byte went from ~40sec to 1.5sec-6sec.
HUGE IMPROVEMENT!! THANK YOU!!
June 29th, 2009 at 22:06
Worked fine for me thanks a lot