Smack Digital Inc.

How To Optimize X-Cart For Speed And Performance

Posted by and last updated Feb 16, 2014 05:51 AM

Optimize your X-Cart for maximum speed and page loads.

For all X-Cart's strengths, speed is certainly not one of them. There are however steps you can and should take to have your X-Cart running faster and performing better.

Administration Changes

The following changes can be made in your X-Cart admin section:

  • Ensure your images are in the file system, not in your database.
  • Disable extra functions and modules that you do not need.
  • The Advanced Statistics module slows down X-Cart by storing statistical information in the database. We highly recommend you disable the advanced statistics module and use a log file analyzer, Google Analytics, and/or a program such as Marketing Manager.

Optimization (X-Cart 4.4.2+)

X-Cart 4.4.2 and greater features an Optimization settings section under the General settings admin section. We recommend enabling the following:

  • Do not check if templates are changed (Smarty compile_check)
  • Do not delete empty strings in templates
  • Use cached buy_now.tpl template calls
  • Do not log changes in PHP configuration settings
  • Do not use product international descriptions on all the product related pages (only if using a single language)
  • Use new module initialization routine

Check Your Benchmarks

X-Cart benchmarking will allow you to see how much time your PHP, Mysql, and Smarty load times are taking. You can check this without presenting the stats to your customers as follows:

Open top.inc.php

# Switching on the internal performance measurement mechanism

// WCM - Speed Optimization
if (!empty($wcm) OR !empty($_GET['wcm']))
define('BENCH', true);
define('BENCH_SIMPLE', false);
// / WCM - Speed Optimization

Then in your browser access your X-Cart as follows: http://www.example.com/?wcm=1

Scroll down to the bottom of the page, and you should see benchmarks. Your total time should be less than 1 second, and ideally around 0.40 seconds or less. If your load times are higher than 1 second, you'll want to do some analysis on what is causing the processing delay and possibly consider moving to a more powerful web server.


Compression works essentially by removing spaces in data to deliver the same content faster as a smaller package. If you're running an Apache server, we recommend the following code which can be added to your .htaccess file to enable compression:

# WCM - Speed Optimization
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# 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

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary

<IfModule mod_headers.c>
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
# / WCM - Speed Optimization

Cache Control

Caching can have a dramatic effect on the speed of your site by preventing content from having to be constantly redelivered to the user. When caching is enabled, a copy of the file is saved to and delivered from the user's computer. If you're running an Apache server, we recommend the following code which can be added to your .htaccess file to enable caching:

# WCM - Speed Optimization
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf|txt)$">
Header set Cache-Control "max-age=31536000"
# / WCM - Speed Optimization

Remove ETags

ETags are bits of information sent from your web server to the user's browser which is used to validate files. By removing the ETag header, you essentially force the browser to rely on your Cache-Control and Expires header as set in the code above. If you're running an Apache server, we recommend the following code which can be added to your .htaccess file to remove ETags.

# WCM - Speed Optimization
Header unset ETag
FileETag None
# / WCM - Speed Optimization


  • Move javascript to .js includes and css to .css includes so that they can be better cached. If using X-Cart 4.4.2 or greater, use the {load_defer} X-Cart function for loading.
  • Optimize your html code so that it is clean and efficient, limit your use of tables, and optimize the size of your images and product thumbnails.
  • X-Cart provides an addon called "Fancy Categories" or "Flyout Menus" - don't use it.
  • Use CSS sprites for layout design wherever applicable.


It's very important to optimize all of your X-Cart tables in your database on a regular basis. This can be achieved using a program such as PHPMyadmin often available as part of your webhosting control panel, or in latter X-Cart versions in the "X-Cart Admin -> Tools -> Maintenance -> Optimize Tables" section.


Using images with larger file sizes than needed can be one of the biggest speed blunders and is one of the easiest to fix. All of your site images, including layout and product images, should be optimized for the web. Check the PNG, JPG, and GIF formats, and determine which provides the best balance of quality and file size before finally saving the file.

Content Delivery Network (CDN)

When a user accesses your website, they connect to your web server where it is located. If you have a web server hosted in the Eastern United States, a person in the Western United States will experience slower access than a person from the Eastern United States. A CDN sets up delivery points at different points across the globe and delivers static content from the point closest to the person requesting the information. This can drastically increase speeds, especially for your international visitors.

Be sure to read our tutorial on How to setup MaxCDN on X-Cart.

Server Configuration

If you are on a dedicated server you will have access to do the following, if not, you may need to speak to your web host.

  • Install Zend Optimizer and Ioncube.
  • Ensure your server has lots of RAM.
  • Have your MySQL settings optimized for your particular needs.
  • Use the Linux "top" function to monitor your server load. If your server load is above 1.00 and it cannot be lowered with optimization, it is too high and you may want to look at a hosting/server upgrade.
  • Enable mysql query caching.


When programming your site, or hiring someone else to program for you, make sure you/they know what you/they are doing! It is very dangerous for a coder to know enough to modify code but not enough to modify it correctly.

About the Author

Jonathan Peters Jonathan's founder of Smack Digital, a digital strategy agency that creates and executes online business success for executives who are highly motivated to quickly increase their market share. With more than two decades of experience on the web for clients ranging from non-profits to billion dollar enterprises, Jonathan's an expert in web development, eCommerce, software programming, search engine optimization and social media marketing.

Browse By Category

RSS Feeds

Don't miss out! Subscribe to our RSS Feeds to receive instant notification when new entries are added.

RSS Feed for All Categories
RSS Feed for X-Cart How-Tos
We choose our clients selectively.
Let's talk success. Apply to work with us.
Apply toWork With Us
Apply toWork With Us