TECHNICAL

Block Caching & 10 Ways to Speed Up Magento

Magento owes its popularity to amazing functionality that allows you to create the online business of your dream. However, you need to pay for that dream, and some businesses pay for it with revenues lost.

Your online store can look great for sure, but Kissmetrics analytics shows that a 1-second page delay of a “heavy” website can cost you up to $2.5 million a year. And Magento stores suffer from being slow with attractive and useful, but heavy features.

how to Speed Up Magento

Tips to Make Magento Performance Glow

Below are the key strategies that will help you to considerably boost the performance of your online store, based on the opinion of our in-house Magento developers.

Reconsider Server Requirements and Configure Optimization

Start with the basics: make sure your website is hosted on a reliable and fast web host. Magento needs powerful servers to give maximum performance. The best choice will be a dedicated server and not a sharing hosting option.

The reason for such a choice is simple: shared hostings support thousands of other websites, making you limited in your resources such as speed and capacity.

And of course, examine Magento system requirements carefully to know what else can be the slowing down factor.

Optimize MySQL Configuration

Another reason your website performance isn’t the brightest can be MySQL configuration. By default, every loaded page starts creating a few database queries. Every query takes time due to slow disk access and loads the server, resulting in worse performance.

The solution is MySQL built-in configuration parameter known as query_cache_size. This feature can store the ready-made result of the query without accessing the disk every single time. Also, MySQL queries can be accelerated by updating Magento indexes.

Enable Flat Catalog for Your Products

If you have a store with a catalog of more than a thousand products, this feature will be especially useful for you. Magento stores the data regarding products and customer info using the EAV model (entity attribute value). Enabling the flat catalog in Catalog settings collects product info into one table, enables faster response to MySQL queries, and therefore improves overall Magento performance.

Speed Up Magento

Combine your JS & CSS Files

There is another built-in Magento feature you can add to your armory. To decrease the page load time, you can merge Javascript and CSS files into one. This is the way to decrease the number of requests significantly.

You can do it yourself manually or via a third-party extension.

Settle for Fewer Extensions

Loading very extensions is an additional time-consuming task for your Magento store. Running more (third party) extensions means getting requests, and more CSS sheets and Javascript files to load, which causes more possible conflicts between third-party extensions and basic Magento. If there are extensions that are not enabled anymore or you can work without, get rid of them.

The fewer extensions your online store has, the faster it gets.

Clean Logs on Time

Magento database keeps logs for 180 days and can become quite heavy, causing slower processing. If your log already counts hundreds of megabytes, it is the right time to clean things up.

Try choosing shorter periods of time like 14 days. Important notice: always backup data first before you change or remove it. The database keeps records of everything about your customers and their orders, and there are pieces of information you might need in case anything goes wrong.

Speed Up Magento website

Do Not Ignore Updates

They are out for a reason. Magento introduces updates when there are bugs are fixed and security is improved. So don’t neglect and don’t postpone updates once the updates coming your way.

The only condition to update without casualties is to make backups before updating to make your data safe. Another tip is to check the release notes before every update. The latest version of Magento. It is recommended to schedule the updates for the time when there is traffic on your online store is relatively low to avoid issues.

Optimize Images

Pictures are an important selling point and you can’t avoid using them or use low-quality images. However, no matter how beautiful they are, heavy images can take an unforgivable amount of time to load. You can losslessly compress all the images up to 70% without losing quality both manually or using third-party extensions.

Set Up Content Delivery Network

With CDN, you can display specific context to your customers, based on their geographic location. This feature is working because of the system of distributed servers. CDN delivers all the page elements from multiple locations and decreases the speed of loading for each of your visitors.

Speed Up Magento 2

Bonus Tip. Use Block Caching

Even quite experienced developers don’t use block caching in their work with Magento. You can also meet a lot of paid Magento themes and modules where this kind of caching is not used at all.

But in fact, using this standard feature is not hard. This feature is part of any Magento block (inherited from Mage_Core_Block_Abstract).

There is a simple example of its usage. For example, on the Home page, we need to display a collection of products which is sorted according to certain criteria. The data on the page should be updated only once a day.

We need to make changes only in two places in the code:

public function __construct()
{
  parent::__construct();
  $this->setTemplate('company/home-product-list.phtml');
  // Block caching setup
  $this->addData(array(
    'cache_lifetime'=> 86400, // (seconds) data lifetime in the cache
    'cache_tags' => array(
      Mage_Core_Model_Store::CACHE_TAG,
      Mage_Cms_Model_Block::CACHE_TAG,
      // tag (can be applied to the number of various blocks)
      // using the tag we can clear the cache of several blocks at a time
      'tag_home_product_list'
    ),
    'cache_key' => 'MY_HOME_PRODUCT_LIST',
 ));

As we see from the example data is kept in cache separately for the store ID, for access using SSL, for access without SSL, for each Package, for each theme, and for the logged-in user and not logged users.

For example, if your Magento uses two stores then the number of copies of the block in cache will be two. In case you use two different Magento themes then the number of copies of the block in cache will be four.

Things to Pay Attention To

Be careful with the attempt to cache the standard blocks like catalog/product_view. The thing is that these blocks are used for rendering several parts of the Product Page. You should understand the following:

1) Where this block is used when the page is rendering.

2) What page parts you want to be cached.

Only after these steps, you can determine the block cache ID and Tag. If you don’t complete these 2 steps you may put in cache page parts that you did NOT plan.

boost magento website

Cache Cleaning

Sometimes you need to clean the cache without waiting to date the cache is expired. There are 2 ways to clear cache:

// Cleaning cache data using ID

Mage::app()->removeCache( ‘MY_HOME_PRODUCT_LIST’ );

// Cleaning cache data using the tag

Mage::app()->cleanCache( array(‘tag_home_product_list’, ‘tag2’, ‘tag3’) );

Always use block caching where it is reasonable.

Bottom Line

As Magento remains one of the most complex platforms to use and develop, it has its perks that allow you to achieve a certain level of bright performance without using any third-party solutions. The thing is, you need to know which buttons to push.

If the task of configuring Magento on your own seems a little bit too monumental for you, we have got your back. There are a few ready-made solutions for cache managing like Cache Pro extension and  Image Magick extension to take care of pictures in your online store.

Subscribe to our newsletter with new materials

Related posts

preloader