Virtuemart Extensions by

  • Full Screen
  • Wide Screen
  • Narrow Screen
  • Increase font size
  • Default font size
  • Decrease font size

Speeding up Virtuemart

One of the common problems with VirtueMart is it's speed. Here we provide advices how you can make your site with 5 thousand products and more to load from 50 to 500 milliseconds (from localhost) depending on actual hardware configration of your server.


Firstly it will work only if you don't have any legacy mode plugins in your Joomla installation. The problem with legacy mode plugins is that they don't support caching top speed caching. Therefore,  if you see that all of your plugins are compatible you can disable Lagacy mode in Joomla. How to find out if everything is compatible? Go to Extensions - Install/Uninstall - Components and you will see column Compatiblity. If all your components are checked, than everything is all right.

Update May 2014

We had built a plugin that is a modification of core's system-cache plugin that is capable of page caching your Virtuemart pages. You may download it from our download area if you have an OPC subscription. The plugin creates page cache for unlogged (anonymous) users with empty cart and no system message pending. 

Php bytecode accelerator / cache is a must have

Check if your hosting has php bytecode accelerator. Php language is usually not encoded/compiled, but written in text. For computer to understand it, it has to be compiled into real computer language of zeros and ones. If this is done for every single visit of your Joomla and Virtuamart site, it is very very slow. This can save you up to 4 seconds load time! And this is the main reason why less visited sites are much slower than more visited sites. I cannot advice you the right bytecode accelerator, because it is very platform dependent. You can have a look into this site to learn more. I had no option to test commercial Zend Accelerator, but from all the rest the only long time stable was APC for my OpenSuse 11.1 installation (i've ran EAccelerator and Xcache).


Step One - Modification of Cache.php

In attachment of this article you can find a modified cache.php file with correct directory structure which you can freely upload to your root directory of joomla. It is modified cache.php according to VirtueMart forum here written by user benm. After uploading this file you can go to Extensions - Plugin manager and turn on "System - Cache" and now not only parts of modules are cached, but whole pages. If you have too much of dynamic content such as Online Users module you should consider not using "system-cache" plugin. Test if everything is ok and if so, you can continue in tuning. Modification of cache.php turns off caching for any user who adds a product to the cart, so VirtueMart can work fluently.


Step Two - Using RAM disk / Memcache / APC

Now when you have your cache generated into /cache directory, it would be very nice for thousands of files not to load from disk, but from something much much faster - RAM. After months of experimenting with session stored by Memcache and APC, my apache server always broke (BECAUSE WE HAD IDENTICAL SECRET IN configuration.php OF JOOMLA on more sites!) and also because we compiled some of the modules incorrectly. If you have professional hosting with professional linux server, you may ask your provider to install Memcache or APC for your site (as php plugins) and test it out and see if it is long-term stable. If you run your site on unlimited virtual server or real server, you may want to create a ramdisk there. Our OpenSuse installation uses dynamic ramdisk in /dev/shm where my scripts can write. Here is the how to:

1, Create a directory in your ramdisk for example /dev/shm/yoursite

2, Delete /cache directory in your joomla installation and create a symlink from /dev/shm/yoursite to /your_joomla_directory/cache where cache is the symlink.

You can do it this way:

# ln -s /dev/shm/yoursite /your_joomla_directory/cache

Now you have a symlink to your ramdisk, BUT after server restart (which should not happen) your symlink will break and your joomla installation MIGHT not work. Therefore we create script and add it to cron after restart:

This is an example of for renewing your symlink after server restart for OpenSuse server. Directories might slightly be different on your installation:




. /etc/profile


#change the following line to your real path to your RAM disk
mkdir /dev/shm/yoursite

#set permissions so your joomla (apache user) will be able to write to the ramdisk disk, you may try to use lower permissions than 777
chmod -R 777 /dev/shm/eurodetektor


#if you have large files (flash, images) which cause you 90 percent of traffic, but are not large all together you can move them to ramdisk as well (notice that you have to create symlink first) In following example it moves files for jsn epic pro template which loads images in flash (which are not cached) and cause 10gb traffic a day to ramdisk. Symlink to /yoursite_realpath/images/stories/header must be already created!


cp -f /yoursite_realpath/images/stories/header_hdd/* /dev/shm/header_hdd
# if you have a bad hosting, this line will tell you if anybody restarted your server (or electricity went down)

/bin/mail -s "Server restart" " This e-mail address is being protected from spambots. You need JavaScript enabled to view it " <<< "server restart"

# if your script can run in root account, you may want to check all the tables in all the databases after restart

mysqlcheck -uroot -ppassword --all-databases=true --auto-repair=true


#end of


Now it is time to add it to cron:

Get to cron

# crontab -e

Press insert to edit

Add new line at the bottom:

@reboot /path_to_your/

Save with: press ESC, type ":wq" with no parenthesis and press enter


Now your cache is generated to ramdisk but that is not enough


Step three - Generate whole cache every twelve hours

If you have your caching set up either on RAM disk or with APC, Memcache you might want it to be generated automatically before first visitor comes and waits 4 to 8 seconds for it to load. The following lines will cause every single possible page from your sitemap to load on localhost and thus create cache. This is my createcache.php:



// ask your hosting provider what is the maximum execution time for php scripts on your server. This script will need approximately 2 to 8 seconds per single item in your sitemap, therefore maximum execution time should be set very high.

set_time_limit(4000); // you might not have permissions to set this

// delete all files
$path = '/dev/shm/';   // this is path to your RAM disk
@deleteFiles($path.'yoursite/');   // this is your directory in RAM disk

// the source is real link to google sitemap of your page. We recommend Xmap as we think it is the best for this purpose, but remember you HAVE TO ADD VIRTUEMART TO THE MAIN MENU otherwise you don't get it to be displayed in your sitemap.
$source = '';


$str = ob_get_clean();

// if you don't need an email about cache created and benchmarks you can comment next line

mail_utf8(' This e-mail address is being protected from spambots. You need JavaScript enabled to view it , 'Cache Created', $str, ' This e-mail address is being protected from spambots. You need JavaScript enabled to view it ');

function mail_utf8($to, $subject = '(No subject)', $message = '', $from) {
$header = 'MIME-Version: 1.0' . "\n" . 'Content-type: text/plain; charset=UTF-8'
. "\n" . 'From: stAn <' . $from . ">\n";
mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $message, $header);

function createCache($source)
$pocet = 0;
$time = microtime(true);

$sitemap = new SimpleXMLElement($source,null,true);

foreach($sitemap as $url) {
// we get contents, but we do nothing with it... joomla generates the cache
$output =  @file_get_contents("$url->loc");

// let's slow down the script a little bit, so your server has a break


$time2 = microtime(true);
$ms = ($time2-$time)*1000;
echo $ms.': '.$source."number of pages: ".$pocet."\n";


// this function is from very helpfull site:

function deleteFiles($path, $match='*', $delSubdirFiles = true)
static $deleted = 0;
$dirs = glob($path."*", GLOB_NOSORT);
$files = glob($path.$match, GLOB_NOSORT);
foreach ($files as $file) {
if (is_file($file)) { unlink($file); $deleted++; }
if ($delSubdirFiles) {
foreach ($dirs as $dir) {
if (is_dir($dir)) {
$dir = basename($dir)."/";
deleteFiles($path.$dir, $match);


return $deleted;



Adding createcache.php to run in cron

If you successfully created createcache.php anywhere on your server disk, you may want to add it to cron. You should test it before and you can remove ob_start and ob_get_clean to get actual echo messages for debuging. Add following line to you cron script

0 */12 * * * nice -n 15 php /yourpathtocreatecache/createcache.php > /dev/null

This script will execute at noon and midnight, it has a low priority, but it doesn't influence MySQL running priority, there check if your server is stable and accepts connections at the time when the script runs. You can do so by checking your webpages on the server or by using top command to see system processes.


Using SSD disks

We are now testing use of SSD disks for database storage and php executables. It really makes your site much much faster if you have low latency disks installed. If you combine SSD disks with in memory caching you should be able to get below 50ms per joomla/virtuemart page load.


How to measure speed of your Joomla/Virtuemart site

Now to test your site you will need ApacheBench "ab.exe" from apache or ab2 if you are under linux. You can download apache here. In windows installation it is in directory /yourapache_install_dir/bin  and you have to get there with cmd (command line). If you have it all installed you can run it from the /bin directory, but don't forget the slash at the end.

ab.exe -c10 -n10

Now you have the results and you can compare your benchmark with other joomla sites.


Save your sessions to shared memory

You have several options how to do it. I prefer to set memory engine and use database to handle sessions. This is a little bit slower than using APC or Memcache, but is much more stable because you never can get in conflict with other Joomla sites on your server. Be very carefull how you set you secret in configuratio.php of your Joomla. If two sites or more have the same secret on one server you will get a very strange results from caching - content mixing and session mixing. Also you may want to use file to save your session data and save the file on ramdisk.

How to set up table jos_session to use memory engine for you VirtueMart installation. You can have a look on this site to see the details.

Ask your hosting provider how much RAM you can use for memory tables. From real world a site with 1000 unique visitors a day running VirtueMart, 60 minutes session time, with 400 active sessions at a time, and Var Char set to length 10000 memory table uses 269Megabytes of RAM.

If you have enough of RAM:

Run this SQL query in phpMyAdmin after clicking on your database, the difference in between Joomla-blog is that you should set data size much higher for VirtueMart to work. I chose 20000, but might but has to be tested. See below.

ALTER TABLE `jos_session` CHANGE `data` `data` VARCHAR( 20000 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL

And this query will change table engine type to be in memory:

ALTER TABLE `jos_session` TYPE = memory

How to find out if Data column length is enough for your installation? Run this query after some time and if you get number similar to what is inside VARCHAR ( 20000 ) than it is not enough!

select session_id, length(data) from jos_session where length(data) = ( select max(length(data)) from jos_session )



FileDescriptionFile size
Download this file ( Modification for JoomlaThis is a file from Joomla 1.5.15 and is compatible up to Joomla 1.5.18 as far as we tested it.1 Kb
Download this file ( 0 Kb
Download this file ( 1 Kb


+2 #1 Peter J 2012-02-21 04:30
Hi, I'm trying to download createcache.php .zip, but it gives an error.

Add comment

Security code

You are here