92014Aug

Magento Optimization – Part 3

In the previous blog we talked about using Memcached and APC as a caching mechanism to improve the speed of our Magento site. In addition to that we can also make other tweaks to improve the performance of our Magento site.

Enable Magento caching

System ->Cache Management.
This is of course the first step in optimization: Enable all the available caches in the Magento Admin Panel.

Magento Cache

Use Magento Compiler module

It’s reported to give you a 25%-50% performance boost: System >Tools >Compilation.
The Magento Compiler module limits the number of directories that PHP has to search through when looking for PHP-files. This decreases the PHP execution-time, which speeds up the Magento application in general. Be warned that you need to be careful when making changes to your Magento system, while the Magento Compiler is enabled. Installation of new plugins and upgrades should only be undertaken when the compiler is (temporarily) disabled.

Magento Compilation

Merge CSS and JavaScript

System ->Configuration ->Advanced ->Developer ->'Javascript settings' and 'CSS Settings'.
By merging all CSS and JavaScript files together as one big file, only one single HTTP-request is needed by the browser to fetch this content. This saves bandwidth.You can also consider using an extensions to do this like the Fooman Speedster extension, whichever works best for you.

Merge Javascript - CSS

Disable Magento logging

System ->Configuration ->Advanced ->Developer ->Log Settings (default is disabled).
Within the Magento configuration, you can enable logging under the Developers-tab. Depending on the Magento modules this could lead to more logs needed to be written to the filesystem, slowing down your shop. Because the logging-abilities are only needed to debug something, in daily usage, it's best to disable logging altogether.

Magento Logging

Disable Modules not in use

System ->Configuration ->Advanced ->Advanced.

Magento Disable Modules

Use Apache mod_expires

By telling the browser which files to keep in cache for how long, you can optimize the browser cache. For instance, JavaScript files tend to change much less then CSS files (at least in the first stages of the site), but perhaps after the site is running smooth for some months you can maximize the expiration date.

In order to ensure that the Magento pages have the correct content expiry in the header, you can add the following block to Magento’s .htaccess file:

ExpiresActive On
ExpiresDefault "access plus 1 month"

Enable Gzip Compression in htaccess

Web pages can be compressed using GZip between the server and the client, reducing the amount of data that needs to be transferred. Although the act of compressing and decompressing adds a performance overhead there is usually a net gain in reducing the amount of traffic especially for large pages. To use GZip compression, enable the mod_deflate module in Apache, and add the following to the vhost for the site:

SetOutputFilter DEFLATE
# 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[678] 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