Magento Optimization Tutorial

How to speed up Magento

In this tutorial we will make some suggestions on how to optimize and speed up your Magento. Always be sure to have a recent backup copy of your Magento files and database before you make any changes to your store, or before you enable options that might potentially break your store.

Compression

You can speed up your Magento by compressing the data sent from the server to the client's browser. This can be done by uncommenting some directives in the .htaccess file in your Magento root directory. For example, if your Magento is installed in a folder called magento on your hosting account, the .htaccess file will be located in public_html/magento.

One way to edit the file is from the Files section of the HostKnox control panel. Find the file there, open it, make the necessary changes and save it. These changes will enable the Apache module mod_deflate for your Magento. The job of this module is exactly to compress data sent from the server to the client. For more information on what exactly you have to edit in the .htaccess file in order to enable HTTP compression read the article on speeding up Magento by enabling HTTP compression.

FastCGI

FastCGI is a protocol, a variation of CGI, which helps the server to process many web page requests simultaneously. It speeds up applications written in different programming languages, such as PHP, Perl, Python, etc. By default HostKnox accounts are configured to use plain CGI. You can switch to FastCGI from the PHP Settings section of the HostKnox control panel. If you experience any problems with FastCGI enabled, you can always switch back to CGI.

Enable Magento Compiler

Magento Compiler is a module that comes prepackaged with Magento. It compiles PHP files that are located in many different directories into a single folder (e.g. public_html/includes/src), and thus the files are executed faster since they are located in one place and there is no need for searching through the various directories. Magento Compiler can be enabled from your store's Dashboard (admin panel). After you log in, go to the System menu, then to Tools and Compilation. On the page that opens click on Run Compilation Process:

Enabling Magento Compiler

Once you enable it, if you wish to disable it later or at any time, just click on the Disable button that appears in the upper right corner after you run the compilation process.

It's a good idea to disable the compiler before you upgrade your Magento, for example, or before you make significant changes. You can enable it after that.

It's also possible that you may experience some problems with your site after you enable the compiler. If you do, just disable it.

Merge CSS and JavaScript Files

By merging the CSS (Cascading Style Sheets) and Javascript files you reduce the number of HTTP (HyperText Transfer Protocol) requests. The fewer the requests, the faster the page will load. The merging can be enabled from your store's Dashboard. Go to the System menu, then to Configuration. At the bottom of the page on the left there is an Advanced menu. There click on Developer. Then you'll see several panels in the middle of the screen, click on ones called JavaScript Settings and CSS Settings to open them. Set the drop-down menus Merge JavaScript Files and Merge CSS Files to Yes:

Enabling CSS and Javascript Merging

Don't forget to click on the Save Config button.

Magento users have reported that sometimes enabling those two options causes some problems to their stores. There is, however, a popular extension that does the same things and more, and that can speed up your store significantly. The extension is called Fooman Speedster.

Fooman Speedster

Fooman Speedster is one of the most widely-used extensions for speeding up Magento. It merges, compresses and caches CSS and Javascript files. It performs the same functions as the PHP application Minify, but it saves you the hassle of setting up everything manually. You can install Fooman Speedster through your Dashboard's Magento Connect (System>Magento Connect). Of course, if you use this extension don't enable the options for merging CSS and Javascript files described above.

If after you install Fooman Speedster the pages of your store's frontend and backend look differently (e.g. the style and colors are all messed up), go to the Files section of the HostKnox control panel and use the tool Fix incorrect permissions. This should fix the problem caused by the file permissions of the directories and files added by the extension to your Magento installation. It's unlikely for this to happen, but if it does, try this solution.

Extensions

Some general advice that applies to all CMS applications (Content Management System) is to use fewer extensions. Naturally, the more extensions you have, the slower the loading time of your site. This doesn't mean that you shouldn't install any extensions, but rather install extensions that you really need and are useful for your site. If there are extensions that you don't need any more, remove them from your site.

Update

Another general advice is to update your Magento store when there's a new stable Magento update. Among other things, updates make various performance and security improvements.

Optimize Images

It's normal for an online store to have a lot of images for the various products. Once you have edited the images to be in the resolution that you need, you can further optimize and compress them. This can be done with an online tool such as Yahoo's Smush.it. It optimizes images to reduce their file size. The image will still have the same quality and resolution but its file size will be a bit smaller. Smush.it only works with images that have a file size of less than 1 MB, and are in one of the following image formats: PNG, JPEG (JPG), GIF.

Optimize Database

You can optimize your Magento database with phpMyAdmin. You can open phpMyAdmin from the Databases section of the HostKnox control panel (there's a link on the right). Once in phpMyAdmin, in the left frame click on the name of the database used by Magento to view its tables. They will be displayed in the right frame. Click on the Check All link at the bottom of the page to mark all the database tables, and then from the With selected drop-down menu choose Optimize table:

phpMyAdmin Database Optimization

Magento has a couple of pages with database tables.

You can do this optimization regularly. From time to time you can also use the Repair table function, in case there are any damaged tables.