Optimizing your website will keep it running smoothly and loading quickly for your site visitors and customers. These tips will help you keep your Magento install as speedy and error-free as possible.
- Enable Output Compression. Turning on the mod_deflate module will enable text, javascript, and css compression. In your Magento .htaccess file, look for the part which starts with <IfModule mod_deflate.c> and ends with </IfModule>. Remove the "#" from the beginnings of all the lines with commands in them, like this:
<IfModule mod_deflate.c> ############################################ ## enable apache served files compression ## http://developer.yahoo.com/performance/rules.html#gzip # Insert filter on all content SetOutputFilter DEFLATE # Insert filter on selected content types only AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript # 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 </IfModule> |
- Enable Expires Headers. This will make some HTTP requests cacheable. This will reduce CPU load and bandwidth consumption. You will need to edit the .htaccess file, starting from the <IfModule mod_expires.c> and ending with </IfModule>, and edit it to match this:
<IfModule mod_expires.c> ############################################ ## Add default Expires header ## http://developer.yahoo.com/performance/rules.html#expires ExpiresActive On ExpiresDefault "access plus 1 year" </IfModule> |
- Merge CSS and JS. This will further decrease the HTTP requests to your server.
- Log into the Magento administration area.
- Select "System", then "Configuration", then "Developer".
- Change "Merge JavaScript Files" to "yes".
- Change "Merge CSS Files" to "yes".
- Clear the Magento cache.
- Enable Flat Catalog. Magento uses long SQL queries and frequent reads. Flat Catalog merges data into one table and improves performance.
- Log into the Magento administration area.
- Select "System", then "Configuration", then "Catalog".
- Under "Frontend" change "Use Flat Catalog Category" to "Yes".
- Under "Frontend", change "Use Flat Catalog Product" to "Yes".
- Clear the Magento cache.
- Database Logs. Magento database logs can become very large quite quickly. You can enable log cleaning this way:
- Log into the Magento administration area.
- Find "Advanced" on the left side and click "System".
- Under the heading "Log Cleaning", change "Enable Log Cleaning" to "Yes" and set the Save Log for 14 days.
- Select "Save Config".
- log.php Utility. Magento has a shell utility which you can configure with Cron or run manually.
For manual configuration, log into your account with SSH and cd to the Magento directory. Enter this:
php -f shell/log.php clean
|
- log.php Cron.
- Log into cPanel.
- Click "Cron Jobs".
- Database Cleaning with phpMyAdmin. You will want to complete this task regularly. The cron job makes automating it easy.
- Log into cPanel.
- Click phpMyAdmin.
- Select the database your Magento installation uses.
- Select the following tables
log_customer
log_quote
log_summary
log_summary_type
log_url
log_url_info
log_visitor
log_visitor_infor
log_visitor_online - Select the dropdown box "With Selected." and choose "Empty".
- Click "yes" at the confirmation screen.