Caching of convertECB, makes the website homepage really slooooow...

Started by glouk7, September 08, 2016, 15:44:32 PM

Previous topic - Next topic

glouk7

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.

GJC Web Design

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?
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Milbo

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;
}
}
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

glouk7

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

glouk7

@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;
}
}


jjk

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.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

glouk7

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)...

jjk

Did you clear all your caches (Admin/Site/Browser)?
Can you post a link to your website, so we can see the issue?
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Milbo



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




When you use the same currency, the cache should not be executed.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

glouk7

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?

glouk7

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...thanks

jenkinhill

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!
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

glouk7

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?

jjk

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.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

glouk7

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.