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.
Open a new console on your Unix server and enter the following command:
sudo mount -t tmpfs -o size=256M,mode=0777 tmpfs /var/www/YOUR_DOMAIN.COM/var/cache/
Tip
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:
tmpfs /var/www/YOUR_DOMAIN.COM/var/cache/ tmpfs size=256,mode=0777 0 0
All the caching mechanisms of Magento will now work with a memory-based filesystem instead of the classical filesystem.
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.