VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: glouk7 on September 08, 2016, 15:44:32 PM

Title: Caching of convertECB, makes the website homepage really slooooow...
Post by: glouk7 on September 08, 2016, 15:44:32 PM
I have an e-shop made with Joomla - Virtuemart.
First of all i want to thank in advance anyone who might read this issue...this is really a headache that i cannot solve and i need assistance from experts.

The issue is that, at the homepage of my website, the load time varies from 20 to 30 seconds...which is amazingly high!
After discussing it with my hosting provider, they found that index.php sends for about 20s requests at the file :

httpdocs/cache/convertECB/86b44edeb1436781d050e4862dd10353-cache-convertECB-bf2c8f06ab151915cd5d7bbef20b70dd.php

In order to help you (if i can) note that:
- If i manually delete the file, joomla recreates the file automatically
- The website uses only one currency (EURO)
- Global configuration cache is off.
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: GJC Web Design on September 08, 2016, 16:55:36 PM
you could try commenting out in administrator\components\com_virtuemart\helpers\currencydisplay.php

/*
if (file_exists( VMPATH_ADMIN.DS.'plugins'.DS.'currency_converter'.DS.$converterFile ) and !is_dir(VMPATH_ADMIN.DS.'plugins'.DS.'currency_converter'.DS.$converterFile)) {
$module_filename=substr($converterFile, 0, -4);
require_once(VMPATH_ADMIN.DS.'plugins'.DS.'currency_converter'.DS.$converterFile);
if( class_exists( $module_filename )) {
$this->_currencyConverter = new $module_filename();
}
} else {

if(!class_exists('convertECB')) require(VMPATH_ADMIN.DS.'plugins'.DS.'currency_converter'.DS.'convertECB.php');
$this->_currencyConverter = new convertECB();

}
*/


but I wonder why it takes so long to load a cached file?
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: Milbo on September 09, 2016, 00:57:35 AM
How works this for you


function convert( $amountA, $currA='', $currB='', $a2rC = true, $relatedCurrency = 'EUR') {

if($currA==$currB){
return $amountA;
}

static $globalCurrencyConverter = false;
if(!$globalCurrencyConverter){
// cache subfolder(group) 'convertECB', cache method: callback
$cache= JFactory::getCache('convertECB','callback');

$cache->setLifeTime(360); // check 4 time per day
$cache->setCaching(1); //enable caching

$globalCurrencyConverter = $cache->call( array( 'convertECB', 'getSetExchangeRates' ),$this->document_address );
}

if(!$globalCurrencyConverter ){
return $amountA;
} else {
$valA = isset( $globalCurrencyConverter[$currA] ) ? $globalCurrencyConverter[$currA] : 1.0;
$valB = isset( $globalCurrencyConverter[$currB] ) ? $globalCurrencyConverter[$currB] : 1.0;

$val = (float)$amountA * (float)$valB / (float)$valA;

return $val;
}
}
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: glouk7 on September 09, 2016, 14:23:50 PM
Quote from: GJC Web Design on September 08, 2016, 16:55:36 PM
you could try commenting out in administrator\components\com_virtuemart\helpers\currencydisplay.php

/*
if (file_exists( VMPATH_ADMIN.DS.'plugins'.DS.'currency_converter'.DS.$converterFile ) and !is_dir(VMPATH_ADMIN.DS.'plugins'.DS.'currency_converter'.DS.$converterFile)) {
$module_filename=substr($converterFile, 0, -4);
require_once(VMPATH_ADMIN.DS.'plugins'.DS.'currency_converter'.DS.$converterFile);
if( class_exists( $module_filename )) {
$this->_currencyConverter = new $module_filename();
}
} else {

if(!class_exists('convertECB')) require(VMPATH_ADMIN.DS.'plugins'.DS.'currency_converter'.DS.'convertECB.php');
$this->_currencyConverter = new convertECB();

}
*/


but I wonder why it takes so long to load a cached file?

I've tried to comment that part, but the site weren't working...(http error 500).

- I am not sure why it takes so long to load a cached file....that's actually the conclusion of my hosting company when i sent them the request to findout why is the website loading so slow.

They said that they "see" that the index.php sends continously requests at that file...
httpdocs/cache/convertECB/86b44edeb1436781d050e4862dd10353-cache-convertECB-bf2c8f06ab151915cd5d7bbef20b70dd.php
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: glouk7 on September 09, 2016, 14:27:51 PM
@Milbo Where this code should be placed ?

Quote from: Milbo on September 09, 2016, 00:57:35 AM
How works this for you


function convert( $amountA, $currA='', $currB='', $a2rC = true, $relatedCurrency = 'EUR') {

if($currA==$currB){
return $amountA;
}

static $globalCurrencyConverter = false;
if(!$globalCurrencyConverter){
// cache subfolder(group) 'convertECB', cache method: callback
$cache= JFactory::getCache('convertECB','callback');

$cache->setLifeTime(360); // check 4 time per day
$cache->setCaching(1); //enable caching

$globalCurrencyConverter = $cache->call( array( 'convertECB', 'getSetExchangeRates' ),$this->document_address );
}

if(!$globalCurrencyConverter ){
return $amountA;
} else {
$valA = isset( $globalCurrencyConverter[$currA] ) ? $globalCurrencyConverter[$currA] : 1.0;
$valB = isset( $globalCurrencyConverter[$currB] ) ? $globalCurrencyConverter[$currB] : 1.0;

$val = (float)$amountA * (float)$valB / (float)$valA;

return $val;
}
}

Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: jjk on September 09, 2016, 15:42:40 PM
I think it is:
...\administrator\components\com_virtuemart\plugins\currency_converter\convertECB.php
Replace existing code (approximately line 40 - 74), but backup the original file first.
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: glouk7 on September 09, 2016, 15:52:34 PM
Quote from: jjk on September 09, 2016, 15:42:40 PM
I think it is:
...\administrator\components\com_virtuemart\plugins\currency_converter\convertECB.php
Replace existing code (approximately line 40 - 74), but backup the original file first.

right i've replaced the code...i don't see any major difference...not it's about 12 seconds (but today was giving me about that amount of time)...
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: jjk on September 09, 2016, 16:55:27 PM
Did you clear all your caches (Admin/Site/Browser)?
Can you post a link to your website, so we can see the issue?
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: Milbo on September 09, 2016, 17:40:54 PM


if($currA==$currB){
return $amountA;
}




When you use the same currency, the cache should not be executed.
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: glouk7 on September 12, 2016, 12:16:28 PM
Quote from: Milbo on September 09, 2016, 17:40:54 PM


if($currA==$currB){
return $amountA;
}




When you use the same currency, the cache should not be executed.
Where do i add this code?
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: glouk7 on September 12, 2016, 12:18:14 PM
Quote from: jjk on September 09, 2016, 16:55:27 PM
Did you clear all your caches (Admin/Site/Browser)?
Can you post a link to your website, so we can see the issue?

Here is the www.e-karonis.gr (http://www.e-karonis.gr)...thanks
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: jenkinhill on September 12, 2016, 13:13:12 PM
Quote from: glouk7 on September 12, 2016, 12:16:28 PM
Where do i add this code?
That code is already present in the code that Milbo provided and that you installed.

Just looked at the url you provided. Yes the home page is slow to render. But it is more than 4Mb in size, with 43 JavaScript files making up 2.3Mb and 31 style sheets making up nearly 1Mb. Astonishing!
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: glouk7 on September 12, 2016, 13:38:24 PM
Quote from: jenkinhill on September 12, 2016, 13:13:12 PM
Quote from: glouk7 on September 12, 2016, 12:16:28 PM
Where do i add this code?
That code is already present in the code that Milbo provided and that you installed.

Just looked at the url you provided. Yes the home page is slow to render. But it is more than 4Mb in size, with 43 JavaScript files making up 2.3Mb and 31 style sheets making up nearly 1Mb. Astonishing!

Hmm...it's quite big size...what can i do to handle and reduce the 2.3Mb of javascript files?
I am not sure if this is the issue though...

*By the way, the page is not developed by me...i've just changed an old template with a new one...
**Tool that you've checked that data?
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: jjk on September 12, 2016, 13:57:37 PM
I would suggest that you use the Firefox browser and install the 'Firebug' plugin. With Firebug enabled you will see some problems if you use the 'Net' tab while loading your website.

1. There is a very long 'time to first byte' (first line in Firebug), which usually is due to a very slow server response.
2. You are still loading K2Store scripts. Did you forget to uninstall that shopping cart?
3. Firebug shows two errors:
TypeError: $(...).set is not a function
$(container).set('html', responseHTML);
k2store.js (line 20, col 9)

"NetworkError: 404 Not Found - http://www.e-karonis.gr//images/stories/virtuemart/noimage.gif"
noimage.gif


4 You are loading two different jQuery versions. I would suggest to disable 'Use external google jQuery library' in VM configuration in case you did enable it.
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: glouk7 on September 12, 2016, 14:43:23 PM
Quote from: jjk on September 12, 2016, 13:57:37 PM
I would suggest that you use the Firefox browser and install the 'Firebug' plugin. With Firebug enabled you will see some problems if you use the 'Net' tab while loading your website.

1. There is a very long 'time to first byte' (first line in Firebug), which usually is due to a very slow server response.
2. You are still loading K2Store scripts. Did you forget to uninstall that shopping cart?
3. Firebug shows two errors:
TypeError: $(...).set is not a function
$(container).set('html', responseHTML);
k2store.js (line 20, col 9)

"NetworkError: 404 Not Found - http://www.e-karonis.gr//images/stories/virtuemart/noimage.gif"
noimage.gif


4 You are loading two different jQuery versions. I would suggest to disable 'Use external google jQuery library' in VM configuration in case you did enable it.

Regarding number 2...is it safe to uninstall those? They were installed from the previous developer, but i am not sure if they are used now.
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: glouk7 on September 12, 2016, 14:44:55 PM
Quote from: jjk on September 12, 2016, 13:57:37 PM
I would suggest that you use the Firefox browser and install the 'Firebug' plugin. With Firebug enabled you will see some problems if you use the 'Net' tab while loading your website.

1. There is a very long 'time to first byte' (first line in Firebug), which usually is due to a very slow server response.
2. You are still loading K2Store scripts. Did you forget to uninstall that shopping cart?
3. Firebug shows two errors:
TypeError: $(...).set is not a function
$(container).set('html', responseHTML);
k2store.js (line 20, col 9)

"NetworkError: 404 Not Found - http://www.e-karonis.gr//images/stories/virtuemart/noimage.gif"
noimage.gif


4 You are loading two different jQuery versions. I would suggest to disable 'Use external google jQuery library' in VM configuration in case you did enable it.

Also regarding 1... it's the answer from the hosting provider...that the index.php tries a lot of times to load convertECB cached file, and that's the reason for the slow response.
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: jjk on September 12, 2016, 15:04:22 PM
Of course I don't know if K2Store pages or content is still used somewhere. You need to figure out that yourself. Perhaps check the K2Store content in the database.
I don't think that two different shopping carts for a single domain would work without problems.

Concerning the ECB requests - you may try a 'simple stupid solution' and unpublish all currencies execpt EUR in VM. Check the first 'Select all' checkbox, unpublish all and then publish EUR again. This is faster than clicking each currency manually in order to unpublish them.
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: Studio 42 on September 12, 2016, 23:11:37 PM
Hi,
Perhaps simply remove all your unwanted javascript,css... and your page load in 2 seconds.
I solved this for some customers, this is only to many file to load and javascript, nothing to do with your convertECB and perhaps on doing some optimisation, you solve the other issue too.
Title: Re: Caching of convertECB, makes the website homepage really slooooow...
Post by: glouk7 on September 13, 2016, 11:53:48 AM
Issue is solved...i've enabled File caching and System caching and now loads in less than 1 sec...

The answers of my hosting company about the converECB file disoriented the way we were looking for solution...

Additionally my fault that in the test website i had xcache caching instead of File...when i managed to change it to File - problem solved...

Thanks anyone here for the time...