5 min read

(For more resources related to this topic, see here.)

Using the Magento caching system

A cache is a system that stores data so that future requests for that data can be served faster. Having cache is definitely a good thing, but the caching system of Magento is not super effective.

How to do it…

Let’s begin with cache enabling, even if most users are well aware of this one. Go to your backend console and then go to System | Cache Management.

By default, all caches are enabled; but some have a negative impact. You have to disable caches for the following items:

  • Collections Data

  • EAV types and attributes

  • Web Services Configuration

The following table shows the improvement made due to the previous settings, that is, by disabling the selected caches:

Another little win, 200 milliseconds, just enough to fulfill the promise made in the previous recipes.

How it works…

A cache is a system that stores data so that future requests for that data can be served faster. A web cache stores copies of documents passing through it, and subsequent requests may be satisfied from the cache if a set of conditions exists.

There are many hypotheses out there to explain this weird optimization. The main one is that the Magento core has to parse the cache and check in MySQL to compare updated data, and this causes a huge delay. In fact, by allowing Magento to do these kinds of operations, we don’t use the full resources of our systems.

Using a memory-based filesystem for caching

We can easily say that the slowest component of a computer is its hard drive. Moreover, the Magento caching system makes massive use of this component. It would be amazing if we could store the Magento cache files directly inside the memory.

How to do it…

Open a new console on your Unix server and enter the following command:


The path is based on a common installation of Apache with Magento; pay attention to your configuration when typing this command.

You have to repeat this command every time the server starts up or you can automatize it by adding the following line into your /etc/fstab file:


All the caching mechanisms of Magento will now work with a memory-based filesystem instead of the classical filesystem.

How it works…

This newly created filesystem is intended to appear as a mounted filesystem, but takes place in the RAM. Of course, the access time of this kind of filesystem is extremely slow in comparison with a classical hard drive. However, all files updated or created are temporary because of the nature of this filesystem. Nothing will be written in the hard drive, and if you reboot everything will be lost. If you plan to reboot your server, you have to save the volatile files in your hard drive, unmount the memory-based system, and then copy the saved data from tmpfs in the cache folder. With the second command, the folder will be remounted automatically after the reboot.


If you have successfully applied all the techniques and your Magento is still slow, it means that you are a very prosperous online retailer and it’s time to leave the comfortable world where there is a single server. To keep your customers satisfied, you have to invest in hardware; the tweaking time is now over.

How to do it…

If you own a single server, you can begin by separating your database in a dedicated server. In order to do this, you have to invest in another server and install MySQL on it (get your host to do it for you), and then extract your database from your first server and import it to your new server. Magento stays on your first server; you have to modify the database connection. Go to /app/etc/local.xml and modify the following lines to fit the new server parameters:


As simple as that. You now use a dedicated database server and improve your store performance.

The second step in clustering our environment could be using a CDN for our images, CSS, and scripts. A CDN is an independent server optimized for delivering static content such as images, CSS, and scripts. In this way, our web server can focus on running Magento and the CDN can focus on displaying static content. The good news is that Magento has native support to do this.

In your Magento backend, navigate to System | General | Web | Unsecure.

If you still have CSS and JavaScript compressed from the previous recipes, you just have to copy your media directory from your main server to your CDN server. If it’s not the case anymore, you have to modify the Base Skin URL field and the Base JavaScript URL field. Also, if for some reason you use the secure URL for that kind of content, don’t forget to apply the changes to the secure part as well.

How it works…

That’s a very good start. Let’s summarize it. We were using a single server for all requests, and now, depending on the request, we use three different servers. The first one handles all the Magento work for building pages, the second one handles the data-related operations, and the last one provides static content. With this kind of architecture, each server can focus on only one purpose.


This article helped you learn Magento’s built-in caching system for saving frequently asked requests. It also introduced you on Magento makes massive use of hard drive which lets you use your available RAM. It also helped you on how to configure a set of loosely connected computers working together for handling more and more customers.

Resources for Article :

Further resources on this subject:


Please enter your comment!
Please enter your name here