Magento速度优化

时间:2012-10-08 13:14:03

标签: xampp magento-1.7

我只是个初学者。我使用xampp1.7.1 php版本5.2.9和Magento 1.7。在我的本地服务器,我想提高magento的速度,为此目的,我尝试了很多技巧,在谷歌找到。但性能仍然没有增加。特别是节省时间(无论我在后端保存的是什么)需要很长时间(5个或更多......)。这是我所做的清单:

  1. 在php.ini文件中:
  2. 更改

    的值
    memory_limit = 8M --> memory_limit = 128M
    query_cache_size=16M --> query_cache_size=64M
    
    1. 在my.ini文件中:
    2. 设置值     key_buffer = 512M     max_allowed_pa​​cket = 64M     table_cache = 512     sort_buffer_size = 4M     read_buffer_size = 4M     read_rnd_buffer_size = 2M     myisam_sort_buffer_size = 64M     tmp_table_size = 128M     query_cache_size = 96M

      1. 在magento .htaccess文件中 取消注释重要的行
      2. 由此:

        <IfModule mod_deflate.c>
        
        ############################################
        ## 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
        
        </IfModule>
        

        对此:

        <IfModule mod_deflate.c>
        
        ############################################
        ## 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
        
        </IfModule>
        
        1. 取消选中“#php_flag zlib.output_compression on”至“php_flag zlib.output_compression on”

        2. 从magento后端启用“缓存管理”

        3. 安装“Fooman_Speedster”扩展程序

        4. 但它的速度仍然没有增加。如果您有任何建议或提示,请与我分享。对不起我的英语不好。 非常感谢。

1 个答案:

答案 0 :(得分:2)

在Windows上开发localy时,有两个常见的延迟原因,localhost的解析是一个,并且由于复杂的操作系统ACL导致Windows文件操作速度慢。

要改善这种情况,必须使用127.0.0.1替换magento安装中的每个localhost条目。有些人在他们的windows hosts文件中创建了一个允许localhost重定向到127.0.0.1的条目,这将改善文件服务时间,但是像PDO connect这样的php命令仍会产生一秒延迟,直到127.0.0.1替换了设置中的localhost。

为了避免Windows缓慢的文件操作,您需要像APC或WinCache这样的操作码缓存php加速器。在Windows中开发时,您可以激活IIS并使用Microsoft Web Platform Installer轻松安装/配置PHP,MYSQL和WinCache。使用xampp时,您可以使用http://downloads.php.net/pierre/http://dev.freshsite.pl/php-accelerators/apc.html二进制文件安装APC,或者使用Visual Studio构建APC,然后使用来自Internet的路线进行配置。根据我的经验,最后一个WinCache版本非常快,它是Windows的真正安全选择。我知道很少有开发人员使用IIS而不是apache,因为IIS过去很糟糕,但此时设置起来比较容易,可以处理更多请求,而且与windows中的apache相比,它在大多数部分都更快。

通过这两项更改,您将看到1000%-200%的改进,而配置MySQL用于生产根本不会使开发环境受益。在htaccess中调整缓存和gzip也不会使本地环境受益,首先是因为您直接从硬盘读取文件(使用内存中的缓存优化器),其次是因为它是一个动态站点,您将在开发过程中不断更改,因此您无法设置过期时间并禁用etags。

为了提高速度,您需要调整模板。简而言之,因为所有的建议都结合了你可以使用的所有png,将你无法组合的那些转换为base64并使用像Lab.js这样的工具来控制加载,这样你就可以确保你的页面加载时间小于1.5秒。转向生产时,使用CDN来提供媒体服务。如果一切顺利,一切都会如此之快,你不会再关心硬件基准,数据库优化和托管比例,直到你每天有数千次访问并提供大量内容。 (静态缓存不是动态页面/部分页面,而是使用magento缓存系统为您的脚本提供最高速度)。

P.S。只要您在阅读许可证时不理解操作系统中的20个并发连接限制,使用Windows客户端版本在www中广播站点是合法的。