Sunday, March 18, 2012

让MAGENTO加速一倍的办法

大家可能都发现了,刚装上MAGENTO的时候,MAGENTO是比乌龟还慢的一个系统。。。 

如何解决呢?其实很多的主机都已经默认安装一个组件:GZIP。 我们就是要通过修改它来提高MAGENTO的运行速度。 

关于能提高多少的问题?大家可以在修改之前去mod_gzip tester 看看你MAGENTO网站的速度,然后在修改之后再去看看。。。 

现在我们为MAGENTO开启GZIP。比较方便的方法是修改根目录下.htaccess 文件。我们只需要去掉一些注释就可以了。 

在根目录.htaccess找到和以下代码相似的代码,并且把代码修改得和下面一模一样。(去掉前面的#符号。) 

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


好了,大功告成,保存你的文件。刷新MAGENTO的缓存,你会觉得速度快了好多好多。

No comments:

Post a Comment