zoukankan      html  css  js  c++  java
  • How to optimize Magento performance

    Overview
    This guide demonstrates how to optimize Magento performance. Most optimizations will work with any version of Magento. Those intended for specific versions will be indicated as such.

    Tweak .htaccess

    The default .htaccess file that comes with Magento has several sections dealing with performance. The following configurations are commented out and must be enabled to realize their benefit.

    Enable output compression

    This section will turn on the apache mod_deflate module, which compresses text, css, and javascript before it is sent to the browser. This achieves a smaller download size. To enable, simply uncomment the appropriate lines so that it looks like the following:

    ############################################
    ## 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 application/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 MSIE !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 expires headers

    Attention: This will not work on LiteSpeed servers.

    Browsers use Expires headers to determine how long a page component can be cached. Static components, like images, should have far-future expires headers, but all page components should have expires headers. To activate this feature, uncomment the appropriate line and add ExpiresActive On directly above it:

    ############################################
    ## Add default Expires header
    ## http://developer.yahoo.com/performance/rules.html#expires
    
        ExpiresActive On
        ExpiresDefault "access plus 1 year"
    

    Disable ETags

    ETags are a way for browsers to validate cached components across subsequent visits. They can slow down a site served from a cluster if the cluster has not implemented them properly. It is best to disable them as follows:

    ############################################
    ## If running in cluster environment, uncomment this
    ## http://developer.yahoo.com/performance/rules.html#etags
    
        FileETag none
    

    Magento administrative tweaks

    Generally, these features are available on versions 1.4.0.1 and higher and should be performed after completing the majority of developmental tasks.

    Combine CSS and JS files

    This feature reduces the number of HTTP requests. For versions earlier than 1.4.x, use the Fooman_Speedster extension instead.

    Attention: Combining CSS/JS when using CDN will cause CSS/JS to "break" until the CDN updates completely. Nexcess recommends starting this process at the beginning non-peak hours to allow enough time for the "new" CSS/JS to reach the CDN.

    1. In the Magento Admin, select System > Configuration > Developer.
    2. Under Javascript Settings, change Merge Javascript Files to YES.
    3. Under CSS Settings, change Merge CSS Files to YES.
    4. Clear the cache.

    Enable flat catalog

    Magento uses the EAV model to store customer and product data. This enables these objects to be incredibly extensible, but results in longer SQL queries and more reads. Enabling the Flat Catalog for Categories and Products merges product data into one table, thereby improving performance. Generally, all stores should enable Flat Catalog for Categories. Stores with over 1000 products should enable Flat Catalog for Products.

    1. From the Magento administator interface , go to System > Configuration > Catalog.
    2. Under Frontend, change "Use Flat Catalog Category" to YES.
    3. If desired, under Frontend, change "Use Flat Catalog Product" to YES.
    4. Clear the cache.

    Other performance tweaks

    Configure the Nexcess CDN

    Clean the database

    Magento's database can quickly become sluggish due to unmaintained log tabes. Refer to Magento Database Maintenance for information regarding database maintenance. 

    - See more at: http://docs.nexcess.net/article/optimizing-magento-performance.html#sthash.gGcybDSA.dpuf

    http://www.magespeedtest.com/

  • 相关阅读:
    iOS(iPho“.NET研究”ne/iPad)开发新手必读 狼人:
    如何解决““.NET研究”呈现控件时出错”的问题 狼人:
    VS2010 测试功能之旅:编码的UI测试(4)通“.NET研究”过编写测试代码的方式建立UI测试(上) 狼人:
    ASP.NET MVC中对数据进行排序的方“.NET研究”法 狼人:
    Android用户界面设计:“.NET研究”创建列表视图程序 狼人:
    Silverlight 2.5D RPG游戏技巧与特效处理:“.NET研究”(四)天气系统 狼人:
    对抽“.NET研究”象编程:接口和抽象类 狼人:
    Silverlight 2.5D RPG游戏技巧与特效处理:(五“.NET研究”)圣赞之HLSL渲染动画 狼人:
    VS2010测试功能之旅:编码的“.NET研究”UI测试(2)操作动作的录制原理(上) 狼人:
    更改“.NET研究”SharePoint 的web.config设置的两种方式 狼人:
  • 原文地址:https://www.cnblogs.com/free3649/p/4070237.html
Copyright © 2011-2022 走看看