Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Improve Magento Performance

You choose Magento as an eCommerce platform for online business because of its one of the widely used CMS for eCommerce business today. Magento as a platform is very robust with a high level of functionality and customization options. It is highly scalable, that means one can start with small online e-commerce business with it and later on can scale up.

According to BuiltWith, 16% of the top 100,000 eCommerce websites are using Magento, 22% if we also include Magento Enterprise. And WooCommerce comes in at a close second with 12%.

Caution: – When Magento is not set up correctly, it will run slowly since it is a ‘heavy’ eCommerce CMS system.

If you run an online eCommerce store based on Magento or work as a Magento developer then this post will help optimize Magento performance and speed up Magneto store pageload speed.

Benchmarking – Whether you are a newcomer, seasoned online retailer, experienced online store owner or Magento developer making an educated decision is the best approach. Balancing the server resources to match customer demand can be a cost-effective way. Often small changes in the server settings might have an impact on the server performance and the customer experience.

Steps to Improve Magento Site Performance for Magento Website Owners

Magento store owners can follow these tips on how to optimize Magento store/website.

Upgrade to the latest version

Magento offers the easiest and smoothest implementation ever offered by any other provider. Keep these benefits intact by upgrading to latest versions. The latest versions come with a more sophisticated option for bug fixing, website optimization, speed optimization, security, and others.

More Magento Resources:
Magento 1 To Magento 2 Migration Process and Steps

Cache Management

Magento’s cache management system is an easy way to improve the performance of the site. But probably it is one of the least understood parts of Magento.

In Magento we have the following cache types:

  • Configuration (non-layout XML files)
  • Layouts
  • Translations
  • Collections Data
  • EAV types and attributes
  • Web Services Configuration
  • Blocks HTML output (Page blocks like headers, footers, and callouts)

When the number of products in the catalog is more than 20,000 or 30,000 then there is approximately an equal number of cache records! Reducing the number of reading operations by keeping trimmed and clean cache is one of the easiest ways of improving store performance.

Magento Content Delivery Network Integration

Slow Magento websites may cost sales. Integrating Magento CDN reduces congestion and dramatically improves access speeds of the website for customers, no matter where in the world they’re located.

To configure a content delivery network:

  • On the Admin panel, click Stores. In the Settings section, select Configuration
  • Select Web under General in the panel on the left
  • Open the Base URLs section, and continue with following:

How to integrate CDN with magneto store

  • In the Base URL for Static View Files field, enter the URL of the location on the CDN where static view files are stored
  • In the Base URL for User Media Files field, enter the URL of the JavaScript files on the CDN
  • Open the Base URLs (Secure) section, and continue with following:

CDN Integration process for Magento

  • In the Secure Base URL for Static View Files field, enter the URL of the location on the CDN where static view files are stored
  • In the Secure Base URL for User Media Files field, enter the URL of the JavaScript files on the CDN
  • When complete, click Save Config

Other eCommerce Resources:
Syspro ERP & Inventory Integration Benefits
eCommerce Website Vs. Marketplace

LiteSpeed Enterprise web server

Replace Apache web server with LiteSpeed Enterprise web server. LiteSpeed offers a 50% performance increase for PHP application and is up to 6 times faster than Apache serving static content.
Reducing server request

Steps to Improve Magento Site Performance for Magento Development Agency/Developers

There are several methods to increase Magento’s frontend performance, ranging from Magento admin panel or Magento development to server or the web hosting configuration, the most commonly missed tweak by many Magento store developers.

.HTACCESS Optimization | Enable Apache Served Files Compression (Gzip)

This technique will enable the Apache HTTP Server mod_deflate module, which through its DEFLATE output filter will compress common text-based content types (including HTML, plain text, XML, CSS, and JavaScript elements) from the server before being served to the client’s browser over the network. This results in a smaller and more efficient download size, often achieving compression rates as high as 70-90% for larger files. To enable this file compression, simply uncomment the following lines within the .htaccess file (or, add them if not already present):

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

.HTACCESS Optimization | Add Default Header Expire

Web browsers make use of a cache to reduce the number of HTTP requests required to download a page and render it; thereby enabling those cached Web page elements to load faster on subsequent visits. Browsers make use of Expires headers to determine for how long a component can be cached. We recommend the following settings:

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

ExpiresActive On
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType text/plain “access plus 15 day”
ExpiresByType text/html “access plus 1 second”
ExpiresByType text/css “access plus 1 day”
ExpiresByType text/javascript “access plus 1 day”
ExpiresByType application/x-shockwave-flash “access plus 1 day”
ExpiresByType application/x-httpd-php “access plus 1 second”

Merge CSS and JavaScript Files

Magento 2 actually has a built-in feature to concatenate (merge) CSS and JavaScript files into one file. This will reduce the total number of HTTP requests and in turn help speed up the loading of pages.

Navigate to “System” → “Advanced” → “Developer.”
Under “JavaScript Settings” and “CSS Settings” change the drop-down to “Yes” and click on “Save Config.”

After combining these files, clear the cache. Follow the process we mentioned earlier.

Clean Up Magento Database & Logs

For Logs:-

By default, Magento keeps logs up to 180 days. This can result in database growing quite large. Change it to something smaller like two weeks (14 days) to save space.

Navigate to “Stores” → “Configuration” → “Advanced”→ “System” → “Log.”

Under “Save Log, Days” change it to 14 days, or whatever is preferred.
Click on “Save Config.”

For Optimize database by execute following sql query in database:-
Let‘s execute this SQL to clear and optimize them
SET foreign_key_checks = 0;
TRUNCATE dataflow_batch_export;
TRUNCATE dataflow_batch_import;
TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
TRUNCATE log_visitor_online;
TRUNCATE report_viewed_product_index;
TRUNCATE report_compared_product_index;
TRUNCATE report_event;
TRUNCATE index_event;
TRUNCATE catalog_compare_item;
SET foreign_key_checks = 1;

Implement Full Page Cache Extension

Speed up Magento stores using cache to the full. Decrease pages time load and improve user experience, which leads to a better conversion rate and higher search rankings.

  • Magento loads pages much-much faster
  • A huge decrease in server load
  • Better search engine indexing and higher rankings
  • Dynamic blocks / “hole punch” support
  • Includes cache crawler!
  • Code Optimization
    For Instance,

    a) SQL queries inside a loop

    Very common bad practice is to load Magento models and process it inside a loop. Running SQL query is a very expensive operation, and doing it in a loop tends to make it even worse. Instead of doing that we could use data collections to load models and then process it. We also need to be careful when working with a collection to do not exceed memory.

    Wrong Practice:
    foreach ($this->getProductIds() as $productId){
    $product = Mage::getModel(‘catalog/product’)->load($productId);
    $this->processProduct($product);
    }

    Good Practice:
    $collection = Mage:getResourceModel(‘catalog/product_collection’)
    ->addFieldsToFilter(‘entity_id’, array($this->getProductIds()))
    ->addAttributeToSelect(array(‘name’));

    foreach ($collection as $product){
    $this->processProduct($product);
    }

    b) Models loading

    We need to remember that each time of executing load () method, a separate query will be executed on a database.

    Also, loading multiple models separately slow down our code. Models should be loaded only once, with a single SQL query.

    Wrong Practice:
    $attr = Mage::getModel(‘catalog/product’)->load($productId)->getAttr();
    $sku = Mage::getModel(‘catalog/product’)->load($productId)->getSku();

    Good Practice:
    $product = Mage::getModel(‘catalog/product’)->load($productId);
    $attr = $product->getAttr();
    $sku = $product->getSku();

    Image Optimization

    Optimizing product images can dramatically increase the speed of pages as this decreases their download times. Compress images (save for web) before uploading them using a tool like Photoshop or there are a number of extensions can be used to auto-optimize them.

    For the mobile site, always declare width and height for them. The recommended image dimensions for mobile Magento store are:

    Product image – 250px / 250px
    Thumbnail – 120px / 120px

    Don’t make the dimension larger and make sure that all product images are of the same dimensions for height and width.

    Enable Flat Categories and Products
    In Magento admin, (top menu) System > Configuration, (left nav) Catalog > Catalog, (main page) Frontend.

    Set “Use Flat Catalog Category” and “Use Flat Catalog Product” to “Yes“.

    The above settings will help increase the performance of Magento website. Do you have another way to speed up Magento that we missed? We would love to hear about it below in the comments.



This post first appeared on I-VERVE TECHNOLOGY, please read the originial post: here

Share the post

How to Improve Magento Performance

×

Subscribe to I-verve Technology

Get updates delivered right to your inbox!

Thank you for your subscription

×