Boost the speed of your Magento

Posted by Tomislav Bilic under Magento @ 30th JUN 2008

Is your Magento slow?

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

Enter your email address to subscribe to new posts:

17 Responses to “Boost the speed of your Magento”


Wow, amazing how much this changes. It’s actually pretty fast now.

Thanks for the advice!

Cheerz, Casper.


You can also play with DeflateBufferSize and DeflateCompressionLevel settings. But don’t make DeflateCompressionLevel too high, though

Tomislav Bilic Said on

Thanks Vladimir,

Can you please present the examples of such usage?


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>

Tomislav Bilic Said on

Thank you :)


Hi!
is this valid for *any* webhosting?

thanks.
-andres

Tomislav Bilic Said on

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.


Wow this works really well, thanks for the advice!


Amazing! Thank you!


my htaccess file already looks like that. i just d-loaded two days ago. am i missing something?


When I try this on Mosso clustered hosting I get a 500 Internal Server error


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?


Thanks, fortunately it did help making magento run three times faster :)


Made a huge difference unreal


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.


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


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

Leave a Reply