Optimizing OpenCart

Learn how to optimize your OpenCart site and boost its performance. Follow our step-by-step OpenCart optimizations to improve speed!

This article describes specific steps you can take to optimize an OpenCart site.

Optimizing OpenCart

There are several modifications you can make to OpenCart that help improve your site's speed and responsiveness. The procedures below show you how to do this so your site is optimized for high performance.

👍

Tip

If you configure the settings as described below and your site's performance is still not at the level you want, there are additional options:

  • Turbo Hosting use a drop-in Apache replacement that can load pages significantly faster than regular web hosting accounts.

  • Managed VPS, Managed Dedicated Server, Turbo Hosting can use Memcached to decrease page load times.

  • Managed VPS and Managed Dedicated Server accounts can use Redis to decrease page load times.

Search engine optimization for URLs

OpenCart includes settings to optimize your store's URLs for search engines, but they are disabled by default. To enable these settings, follow these steps:

  1. Using the cPanel File Manager or the SSH command prompt, in the directory where you installed OpenCart, rename the .htaccess.txt file to .htaccess. The .htaccess file contains rewrite rules for the sitemap file and other URLs.

    🚧

    Important

    If you installed OpenCart in a subdirectory beneath the public_html directory, you must make an additional modification to the .htaccess file. To do this:

    • Using the cPanel File Manageror the SSH command prompt, open the .htaccess file in your preferred text editor.

    • Locate the following line of text:

    RewriteBase /
    
    • Add the name of the directory where you installed OpenCart. For example, if you installed OpenCart in the public_html/shop directory, type /shop.

Apache optimizations

You can add compression and caching directives to the .htaccess file in OpenCart's root directory to help decrease page load times for your site.

Compression

The Apache mod_deflate module enables you to compress output. This both saves bandwidth and ensures faster page download times. To enable output compression for OpenCart, follow these steps:

  1. Open the .htaccess file in your preferred text editor.

  2. Add the following lines to the .htaccess file:

    <IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/html text/css text/javascript application/javascript
    </IfModule>
    
  3. Save your changes to the .htaccess file. The changes take effect immediately.

Browser caching

The Apache mod_expires module enables you to instruct web browsers how long to cache certain types of content. This both saves bandwidth and ensures faster page download times. To enable browser caching directives for OpenCart, follow these steps:

  1. Open the .htaccess file in your preferred text editor.

  2. Add the following lines to the .htaccess file:

    <IfModule mod_expires.c>
        ExpiresActive On
        ExpiresByType image/gif "access plus 1 month"
        ExpiresByType image/jpeg "access plus 1 month"
        ExpiresByType image/png "access plus 1 month"
        ExpiresByType text/css "access plus 1 week"
        ExpiresByType text/javascript "access plus 1 week"
        ExpiresByType application/javascript "access plus 1 week"
        ExpiresDefault "access plus 1 week"
    </IfModule>
    

    👍

    Tip

    If your store's content changes frequently, you can shorten the expiration intervals. The settings above should be sufficient for the majority of store configurations, however.

  3. Save your changes to the .htaccess file. The changes take effect immediately.

Product counters for categories

By default, OpenCart counts the number of products in each subcategory. If your store has a lot of subcategories, however, this feature can negatively affect performance. To disable product counters, follow these steps:

  1. Log in to OpenCart as the administrator.

  2. Do one of the following steps:

    • If you are running OpenCart 1.5, on the top menu bar, click System, and then click Settings.

    • If you are running OpenCart 2.0, in the left pane, click the OpenCart - Settings icon icon, and then click Settings.

  3. Do one of the following steps:

    • If you are running OpenCart 1.5, select your store, and then click Edit.

    • If you are running OpenCart 2.0, select your store, and then click the Edit (OpenCart - Edit icon) icon.

  4. Click the Option tab.

  5. Under Products, for the Category Product Count option, click No.

  6. Do one of the following steps:

    • If you are running OpenCart 1.5, click Save.

    • If you are running OpenCart 2.0, click the Save (OpenCart - Save icon) icon.

Related Articles