- May 3, 2013
- Posted by: Admin
- Category: Magento
Let’s begin with the basics of Magento Performance and Speed Optimization Tips. Tips here are mainly just configuration tweaks. They are easy to implement and test. And if you don’t like them you can easily revert all your changes. Make sure you restart your service after the configuration change.
We will cover 5 easy points in this article, additional methods will be explained in the advanced article:
- Save the sessions in database
- Enable Magento Cache
- MySQL Query Cache
- Enable file compression in .htaccess
- Clean up the template
Save the sessions in database
It’s better to save the sessions in the database rather than the file system; this allows much, much faster access of all sessions. Magento supports this very well.
Expected effect: For small stores, the improvement may be relatively small, but if you have a sizable store with concentrated traffic, the effect is quite appreciable.
You can choose to save sessions to database during your Magento installation.
Or you can edit the app/etc/local.xml:
Enable Magento Cache
This is almost trivial, but very important. The fact is, in many cases, the cache might be disable manually by developer, so that any code update will take effect immediately. But unfortunately, the cache may stay disabled when eventually the Magento store is deployed on a live server.
Expected effect: Significant in all cases. This is a must.
In the admin panel, under System > Cache Management, just make sure that all caches are enabled.
In fact, system cache is the major target for Magento performance improvement. A very effective way is to use RAM disk. This is beyond the scope of this article, and we will talk about the details in Speed up your Magento site (Advanced).
MySQL Query Cache
MySQL offers a very handy feature: ‘Query Cache’. This is indeed a good solution to handle the Magento EAV data model, which tends to produce ‘heavy’ queries.
Expected effect: This one is sensitive to large EAV objects in your store, especially ‘products’. For stores with less than 1,000 products, the effect would be hardly appreciable. For stores in the 1,000~10,000 range, this is optional, a cache of size 16M~32M can bring some improvements. But for stores with 10,000+ products, this is almost a must.
Modify my.conf as the following (you will need root access) :
You need to restart your MySQL server after done.
Enable file compression in .htaccess
Expected effect: The result can be dramatic on stores running on shared hosting. If you already have a very good dedicated server, the effect may not be obvious.
By default, this option is commented out in Magento .htaccess file. Just uncomment this part so it looks like:
## enable apache served files compression
# Insert filter
# 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 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
Clean up your template
However this is more than just a configuration change, and We will talk about the details in Magento Speed up (Advanced).