Contact
Site: US UK AU |

How to optimize Magento performance

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 included with Magento includes several sections discussing performance. Comment out the following sections and enable them to apply their benefits.

Disable ETags

ETages allow browsers to validate cached page components from visit to visit. While useful, they can hamper websites hosted on server clusters in some cases. Disabling them as follows will often improve performance: 

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

    FileETag none

Enable Expires headers

Attention: The following will not function on LiteSpeed servers.

Browsers use Expires headers to define the lifespan of cached page components. While all page components should include Expires headers, static components and images should use far-future Expires headers. 

To activate this feature, uncomment the appropriate line and, directly above it, add ExpiresActive On. For example:

############################################
## Add default Expires header
## http://developer.yahoo.com/performance/rules.html#expires

    ExpiresActive On
    ExpiresDefault "access plus 1 year"

Enable output compression

This section discusses how to compress both static content such as text, CSS, JavaScript, and individual HTML files, and dynamic content such as content generated by CMSs like Magento, WordPress, and ExpressionEngine, among others.

Static content

This will activate the Apache mod_deflate module and compress static resources into smaller files before transfer to the browser. To enable, uncomment the appropriate lines as shown below:

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

Dynamic content

If, however, your site relies on dynamically generated content, instead create a file called .user.ini in your site's document root folder with the following contents:

zlib.output_compression = on

If you are a Nexcess client, we can make this the default setting for your account upon request. 

Magento administrative tweaks

These features are generally available on versions 1.4.0.1 and later. However, we recommend applying them only after concluding the majority of your 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 a CDN will break CSS/JS until the CDN updates. Therefore, we recommend starting this process during early non-peak hours.

  1. In the Magento Admin, select System > Configuration > Developer.
  2. Under Javascript Settings, from the Merge Javascript Files drop-down list, click YES.
  3. Under CSS Settings, from the Merge CSS Files drop-down list, click YES.
  4. Clear the cache.

Enable flat catalog

Magento uses the EAV model to store customer and product data. This upgrades extensibility at the cost of prolonging SQL queries. 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 administrator interface, go to System > Configuration > Catalog.
  2. Under Frontend, from the Use Flat Catalog Category drop-down list, click YES.
  3. If desired, under Frontend, change Use Flat Catalog Product to YES.
  4. Clear the cache.

Other performance tweaks

Configure the Nexcess CDN

For details, refer to How to configure CDN access for Magento

Clean the database

Magento's database can quickly become sluggish due to un-maintained log tables. Refer to How to perform Magento database maintenance for more information. 

 

For 24-hour assistance any day of the year, contact our Support Team by email or through the Client Portal.

Article Rating (8 Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
 
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
How to change your Magento 1.x password
Added on Wed, Nov 30, 2016
How to enable system error logging in Magento 1.x
Added on Wed, Sep 19, 2018
How to issue a reindex in Magento
Added on Fri, Nov 15, 2013
What is Turpentine?
Added on Thu, Aug 28, 2014
How to set the return-path email in Magento
Added on Thu, Oct 30, 2014
How to configure Magento to use your SSL certificate
Added on Mon, Feb 29, 2016
How to disable maintenance mode in Magento
Added on Fri, Dec 15, 2017
What is Magento?
Added on Thu, Sep 10, 2015
How to find and remove hanging Magento cron jobs with SSH
Added on Thu, Oct 30, 2014
How to configure CDN access for Magento
Added on Wed, May 16, 2018