In my previous post, I explained some of the basic settings that anyone should be able to implement to improve the speed of your X-Cart website.
In this post I’m going to entertain some intermediate level tasks to improve website performance. Some of these steps will require some editing of files that not every user will feel comfortable changing. If you don’t feel comfortable making the changes, contact your web host or a competent web developer to make the changes for you. (here’s my contact page if you are looking)
The bonus on most of these changes is they can affect more than just X-Cart. You can use them for other shopping carts, and they’ll even speed up the performance of other systems such as WordPress or Forums that you might be using.
Intermediate Performance Updates for X-Cart
- Compress output from your server – Most hosting you’ll find should be up to date with Apache 2 and if this is the case then you should utilize Mod_deflate to compress output from your server. Gzip can generally can reduce the response size by 70%. Keep in mind this is the size not directly performance of X-Cart, but as we all know the smaller it is the faster a visitor can download and see it. Approximately 90% of todays traffic is through browsers that support Gzip. So if it’s available use it but make sure if it’s not available it doesn’t Gzip. Here’s what you can add to your .htaccess file to produce this effect:
<ifmodule mod_deflate.c>
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter
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
</ifmodule> - Add Expires or Cache-Control Header - By adding an expires header you are setting up elements of your site to be cached on the visitors computer to ensure that they do not download the same files over and over. Every request on your server has an over head on it and takes time. Images, CSS files, Javascript files, these are all elements that don’t change throughout your site, so make sure your visitors are caching these. Yahoo measured the improvement on visitors view subsequent pages views with a “primed cache” to be an improvement of 75-80%. Add the following to your .htaccess file:
<ifmodule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
</ifmodule> - Improve Apache performance by removing htaccess – Your htaccess file is a very handy tool, you can implement changes to the Apache configuration directly in the filesystem. But this isn’t always the best method for a production server. For every request to the server Apache reads this file determines the configuration options and then proceeds with what needs to be done. Once you work out the details of your configuration you should move these configuration changes into the Apache Virtual Hosts configuration. Then you just restart Apache it reads and loads all the configuration into memory and remains there for easy, fast access. You probably won’t notice a huge improvement here, but it will definitely make a difference and every improvement helps.
- Enable Smarty Caching – X-Cart and several other systems use the Smarty Template Engine to template what the visitors see. Smarty will check every template every single time it is used to see if it is different from the last time it was built. If it is different it rebuilds the template, if it’s not then it just loads it’s existing cache. If you are on a production server, turn this check off. You probably change your templates about twice a year? This is under Intermediate for two reasons, one it’s a file that needs to be found and changed, but also you’ll need to remember from now on to just clear your template cache every time you make changes to the templates. In X-Cart 4.3.x you’ll find the file that needs to be changed at /include/lib/smarty/Smarty.class.php and the change you need to make is:
Approximately line 141 change:
var $compile_check = true;
to:
var $compile_check = false; - Tune your MySQL configuration – Always keep in mind that X-Cart, as well as other dynamic scripts, require a database connection. This is where all the information is stored to generate the dynamic pages. Make sure you are maximizing your available memory with your MySQL configuration. Remember on the previous article that memory is an important aspect of your web hosting. The more products, the more options and especially the more product variants you have, the more important these settings become. With a small store you can probably get by with a query_cache_limit of 1 Mb, but with larger stores you’ll want to test out a larger limit such as 64 Mb. There are many other settings as well, but be careful here, in some cases setting a limit too high can cause a decrease in performance. Not to mention you are taking memory away from other applications such as Apache.
I think that’s good enough for now. Implementing the last 10 changes should put you in pretty good standing with your website performance. In the next post we are going to tackle some more advanced options that will require some server application installations.









10:33 am
Nice tips, been on X-cart for few years now and will consider this..
9:10 am
Thanks these really helped, especially changing the images from the DB to the filesystem, what a difference