Topmagento.com|Magento技术交流站

利用开启.htaccess里面的gzip功能来优化magento速度

栏目:magento优化      3,070 views      2 枚回复

目前magento相对于其他像zencart、oscommerce等开源商城系统速度算最慢的,虽然magento1.4x 稳定版已经发布了(右侧可点击下载),magento整体性能有所提高,速度方面也有显著提高,不过对于使用者来说是往往不够的,提高magento速度是一个重点。当然,提高magento速度的方法有很多种,这里主要介绍 “如何利用开启.htaccess里面的gzip功能来达到提升magento速度的目的”。

首先,你需找到magento 的根目录下的.htaccess文件,这个是apache服务器的配置文件,没有它,整个系统无法再Apache服务器上运行。

第一点:找到大概第76行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
############################################
## 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

修改为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
############################################
## 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行:

1
2
3
4
############################################
## enable resulting html compression

#php_flag zlib.output_compression on

确保这里是“on” 。
好了,大功告成了。修改后保存上传覆盖即可。速度可以显著提升两倍多。


标签:

转载注明:转自Topmagento.com|Magento技术交流站

本站遵循:署名-非商业性使用-禁止演绎 3.0 共享协议

收藏分享: QQ书签 / 百度收藏 / Google书签 / 收藏到鲜果 / Digg / Del.icio.us


2 枚回复


  1. weddingdressesgo 说道:

    谢谢,好了一些了。

    [回复]

  2. zen cart 说道:

    速度真的快了一些,感谢博主分享

    [回复]


发表回复


XHTML: 您可以使用如下代码:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>