目前magento相对于其他像zencart、oscommerce等开源商城系统速度算最慢的,虽然magento1.4x 稳定版已经发布了, magento整体性能有所提高,速度方面也有显著提高,不过对于使用者来说是往往不够的,提高magento速度是一个重点。当然,提高magento速度的方法有很多种,这里主要介绍 “如何利用开启.htaccess里面的gzip功能来达到提升magento速度的目的”。
首先,你需找到magento 的根目录下的.htaccess文件,这个是apache服务器的配置文件,没有它,整个系统无法再Apache服务器上运行。
第一点:找到大概第76行
############################################
## 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 apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter on all content
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
第二点:找到第49行:
############################################
## enable resulting html compression
#php_flag zlib.output_compression on
确保这里是“on” 。
好了,大功告成了。修改后保存上传覆盖即可。速度可以显著提升两倍多。