VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: micpic on April 21, 2015, 09:48:58 AM

Title: Category Cache Problem VM 3.0.8
Post by: micpic on April 21, 2015, 09:48:58 AM
Hello,

we are new in VM and learn the last 14 days much of the functionality. But now we have a major Problem
for us.

If we generate a new category over the Administrator Backend we see the category in the Joomla VM BAckend
but it is dont visible in the frontend for any times.
We disable all of joomla abd Template cache and disable the cache in the VM category modul too.
After five minutes we can see our Category changes in the frontend

We work with the "GAVICK shop an Buy" VM Template

We check this Issue in the Joomla Beeze Templates too wit the same result. And yes we look into the forum and find many entrys for caching problems with VM, but never fix it
or we dont find it.

We are very glad you can see us a way to fix this problem.

System: Joomla 3.4.1
VM: 3.8.0
PHP: 5.4.29

Best Regards
Michael


Title: Re: Category Cache Problem VM 3.0.8
Post by: GJC Web Design on April 21, 2015, 10:10:23 AM
It isn't a problem as such - it is the way it works

caching of the cats gives a huge speed improvement to a client browsing

if you want to clear the cache after a cat change simply go -> Joomla admin->system->clear cache
you will see the vm cats cache - com_virtuemart_cats - delete
Title: Re: Category Cache Problem VM 3.0.8
Post by: micpic on April 21, 2015, 10:31:25 AM
Oh no,

iam so sorry. we disabled all of cache functions into to system and this is the reason that we ar dont take a look into the system cache.

OK now we see VM is writing into the system cache anytime.

Many thanks for your fast help.

Michel
Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on April 21, 2015, 10:42:26 AM
it would be so simple to clear the know cache in the model when recording a category :

$conf = JFactory::getConfig();
$options = array(
'defaultgroup' => 'com_virtuemart_cats',
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache');

$cache = JCache::getInstance('callback', $options);
$cache->clean();
// mod product
$options['defaultgroup'] = 'mod_virtuemart_product';
$cache = JCache::getInstance('callback', $options);
$cache->clean();
// mod category
$options['defaultgroup'] = 'mod_virtuemart_category';
$cache = JCache::getInstance('callback', $options);
$cache->clean();

But this must be approved by the main developer.
Title: Re: Category Cache Problem VM 3.0.8
Post by: Milbo on April 21, 2015, 11:05:42 AM
Patrick, you are really .... unbelievable.
Please stop the permanent accusations and bitching. It is really genioius to go in our config model and copy line 458-472. Constructive would be to provide a patch adding exactly the missing line to the category model. If you would be willing to help and not just show how great you are and how dumb we are, you would get the fact that the cache is cleaned at 4 different places in the config model. So the question is not how todo that, the question is why it does not work for them as expected.
Title: Re: Category Cache Problem VM 3.0.8
Post by: Milbo on April 21, 2015, 11:23:17 AM
Quote from: micpic on April 21, 2015, 09:48:58 AM
And yes we look into the forum and find many entrys for caching problems with VM, but never fix it

That does not mean it is not fixed. Yesterday I tried to find any post with "cant store product" which happened due an update to j3.4.1. It is fixed. There are more than 20 threads about it. 95% of them were created AFTER the fix was already released! So it is very likely the same here. There are none known problems with caching left.


Quote from: micpic on April 21, 2015, 09:48:58 AM
VM: 3.8.0
vm3.0.8 please :-)
Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on April 21, 2015, 11:28:14 AM
First, i never said you are dumb,
second this is a proposal, not a final patch.

And i tried this, but the problem in Joomla is that when the cache is not active, my patch does not work, but this solve the problem for mod_category and mod_product(for alias).
In all case the current problem is Joomla cache system not virtuemart.
I don't understand. You don't want to find a solution ?
Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on April 21, 2015, 12:02:27 PM
This is a real working solution :
JOOMLAROTH/administrator/components/com_virtuemart/models/category.php
in public function store(&$data) { insert

$conf = JFactory::getConfig();

$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);
$cache->clean('com_virtuemart_cats');
$cache->clean('mod_virtuemart_product');
$cache->clean('mod_virtuemart_category');


this work when joomla cache is active or not. tested in Joomla 3.4
Title: Re: Category Cache Problem VM 3.0.8
Post by: Milbo on April 21, 2015, 12:55:12 PM
Looks good Patrick. I have to dig through it again, but

$conf = JFactory::getConfig();

$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);

is an idea. I must also first check if it is j3 problem only.
Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on April 21, 2015, 13:11:25 PM
I checked in com_cache model to find how joomla dev have do this.
In Joomla 2.5, the code is same as in joomla 3.4, this mean the code is certainly safe.
Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on April 21, 2015, 16:53:38 PM
same code for config model clean cache

$conf = JFactory::getConfig();

$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);
$cache->clean('com_virtuemart_cats');
$cache->clean('com_virtuemart_rss');
$cache->clean('com_virtuemart_cat_manus');
$cache->clean('convertECB');
$cache->clean('_virtuemart');
$cache->clean('com_plugins');
$cache->clean('_system');
$cache->clean('page');
$cache->clean('mod_virtuemart_product');
$cache->clean('mod_virtuemart_category');


But the config, is not so important.

for manufacturer model in public function store(&$data) {
$conf = JFactory::getConfig();

$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);
$cache->clean('com_virtuemart_cat_manus');

Title: Re: Category Cache Problem VM 3.0.8
Post by: franzpeter on April 23, 2015, 11:46:52 AM
@Studio 42
I did try to implement your patch in case of categories. With J 2.5 it does not work. I receive error message. In case of J 3 it is completely ignored. So by default seems to be useless. Is it a solution for an non existing problem? I do not know what was wrong with the caching before. I can delete the cache via Joomla in J 2.5 and J 3.4.1. It is recreated if going to the FE. If  - in case of the category module - the caching is set to none in BE, there will be no cache. So I do not understand exactly that solution. There is no problem and you write something for a non existing problem.
Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on April 23, 2015, 16:17:04 PM
Hi,
Virtuemart always force the cache for the category aliases.

But the fix is when you save the category not after. But why you have to change the aliases after saving, because this have to be correct if you don't do any change in Back end.

I tested the patch, perhaps you have do a mistake on copy/paste ?

Greets,

Patrick
Title: Re: Category Cache Problem VM 3.0.8
Post by: Milbo on April 26, 2015, 12:19:10 PM
Works also not for me, Patrick
Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on April 26, 2015, 13:54:35 PM
This is exactly what i have in file administrator\components\com_virtuemart\models\category.php in the store function :

    public function store(&$data) {

vRequest::vmCheckToken();

$table = $this->getTable('categories');

if ( !array_key_exists ('category_template' , $data ) ){
$data['category_template'] = $data['category_layout'] = $data['category_product_layout'] = 0 ;
}
if(VmConfig::get('categorytemplate') == $data['category_template'] ){
$data['category_template'] = 0;
}

if(VmConfig::get('categorylayout') == $data['category_layout']){
$data['category_layout'] = 0;
}

if(VmConfig::get('productlayout') == $data['category_product_layout']){
$data['category_product_layout'] = 0;
}

$table->bindChecknStore($data);

if(!empty($data['virtuemart_category_id'])){
$xdata['category_child_id'] = (int)$data['virtuemart_category_id'];
$xdata['category_parent_id'] = empty($data['category_parent_id'])? 0:(int)$data['category_parent_id'];
$xdata['ordering'] = empty($data['ordering'])? 0: (int)$data['ordering'];

    $table = $this->getTable('category_categories');

$table->bindChecknStore($xdata);

}

// Process the images
$mediaModel = VmModel::getModel('Media');
$file_id = $mediaModel->storeMedia($data,'category');

$conf = JFactory::getConfig();

$options = array(
'defaultgroup' => '',
'storage' => $conf->get('cache_handler', ''),
'caching' => true,
'cachebase' => $conf->get('cache_path', JPATH_SITE . '/cache')
);
$cache = JCache::getInstance('', $options);
$cache->clean('com_virtuemart_cats');
$cache->clean('mod_virtuemart_product');
$cache->clean('mod_virtuemart_category');

return $data['virtuemart_category_id'] ;
}


When i disable the cache in Joomla, all this 3 folders com_virtuemart_cats, mod_virtuemart_product, mod_virtuemart_category are removed and if i enable the cache this work same.
Of course, at the moment you refresh a page in the front, the  com_virtuemart_cats folder are regenerate, because this cache is forced in virtuemart.
I don't try to solve the foced cache problem, but my problem was that on saving a category, this was not refreshed in the 3 core caches using categories.
P.S: this fix is running on my test server without any error in my error log seens 4 days now.
Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on June 30, 2015, 17:12:28 PM
Hi,
I see all day this cache problem, Why the team does not try to add my solution or another one?
Title: Re: Category Cache Problem VM 3.0.8
Post by: jjk on June 30, 2015, 22:23:54 PM
Quote from: Studio 42 on June 30, 2015, 17:12:28 PM
I see all day this cache problem, Why the team does not try to add my solution or another one?
Is it still a problem? I found only this forum thread about a possible category cache problem. In the case above (original post from April) it might also be related to a GK framework cache, which could still be active after changing the frontend template. With my installed templates, I couldn't reproduce the issue.
Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on July 01, 2015, 00:10:29 AM
Hi jjk, the problem is only that the cache get not refreshed when you save the category(and manufacturer)
This mean for eg, the link(alias) to a category can be wrong the time the cache is not expired or you clear the cache in Joomla.
This is not a so big problem, but this make trouble for some users.
I had report in virtuemart french forum, here in forum, by PM(to get a solution), in some other sites.
Title: Re: Category Cache Problem VM 3.0.8
Post by: franzpeter on July 01, 2015, 11:16:26 AM
My opinion is: VM should not do any forced cache. Joomla allows to switch on or off the cache inside the configuration tab. If switched off, no cache should occur. If someone wants to use cache for categories it should be customers decision.
Title: Re: Category Cache Problem VM 3.0.8
Post by: Mayapi on February 18, 2016, 00:00:08 AM
Hello friends from France,

i have also a problem with the cache of Virtuemart 3.0.12 ...

The "search in the shop" module and the "filter by price" module run normally when i have clean the "com_virtuemart_cats" into the purge cache of joomla 3.4.8, but after i refresh the page the "com_virtuemart_cats" reappear each time and i lose the functionnality of the two module. They find nothing, simply seams very stuck due to cache.

I have check all modules cache and plugin page cache to NO.

My question is: How is it posssible to remove the cache system of the "com_virtuemart_cats" ?

Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on February 18, 2016, 02:00:18 AM
Quote from: Mayapi on February 18, 2016, 00:00:08 AM
Hello friends from France,

i have also a problem with the cache of Virtuemart 3.0.12 ...

The "search in the shop" module and the "filter by price" module run normally when i have clean the "com_virtuemart_cats" into the purge cache of joomla 3.4.8, but after i refresh the page the "com_virtuemart_cats" reappear each time and i lose the functionnality of the two module. They find nothing, simply seams very stuck due to cache.

I have check all modules cache and plugin page cache to NO.

My question is: How is it posssible to remove the cache system of the "com_virtuemart_cats" ?


Hi Mayapi,
Currently, it's not possible, only if you hack the core, you can disable it.

Here why in JOOMLAROOT\administrator\components\com_virtuemart\helpers\shopfunctions.php :

static public function categoryListTree ($selectedCategories = array(), $cid = 0, $level = 0, $disabledFields = array()) {

$hash = crc32(implode('.',$selectedCategories).':'.$cid.':'.$level.implode('.',$disabledFields));
if (empty(self::$categoryTree[$hash])) {

$cache = JFactory::getCache ('com_virtuemart_cats');
$cache->setCaching (1);
$app = JFactory::getApplication ();
$vendorId = vmAccess::isSuperVendor();
self::$categoryTree[$hash] = $cache->call (array('ShopFunctions', 'categoryListTreeLoop'), $selectedCategories, $cid, $level, $disabledFields,$app->isSite(),$vendorId,VmConfig::$vmlang);

}

return self::$categoryTree[$hash];
}


$cache->setCaching (1); force to use the cache.
If you comment it
// $cache->setCaching (1);
Then caching is active if Joomla cache is active.

I personally use a categories cache in controller on my sites and for module too when it's possible, so this VM cache do not speed up my site.
I think this cache should be optional, you have other way to speed up this eg. On implementing Cache in VM category controller i win more then 500ms for 24 products. And when page is in cache this function get not called anymore.
So you have double cache for nothing.

Perhaps someone from team want add this as a setting in Config ?
Title: Re: Category Cache Problem VM 3.0.8
Post by: Mayapi on February 18, 2016, 16:06:52 PM
@Studio 42

Virtuemart is an awesome e-commerce for Joomla, for sure if i was a beast coder in php ill do an extra function with enable/disable cache, but i think its not the priority of the devs today.

And not hopefully for me your comment dont work for me, i have try to comment like your script, and have try to turn the number to 0, have try all codes in first page of the topic but it do nothing more.

I think the cache is more complex than a simple function on this shopfunction.php
Title: Re: Category Cache Problem VM 3.0.8
Post by: Milbo on February 18, 2016, 16:59:32 PM
Quote from: Mayapi on February 18, 2016, 00:00:08 AM
Hello friends from France,
Little hint, there is a virtuemart forum in france virtuemart.fr.

Quote from: Mayapi on February 18, 2016, 00:00:08 AM
i have also a problem with the cache of Virtuemart 3.0.12 ...
You dont.

Quote from: Mayapi on February 18, 2016, 00:00:08 AM
The "search in the shop" module and the "filter by price" module run normally when i have clean the "com_virtuemart_cats" into the purge cache of joomla 3.4.8, but after i refresh the page the "com_virtuemart_cats" reappear each time and i lose the functionnality of the two module. They find nothing, simply seams very stuck due to cache.
The cache com_virtuemart_cats has nothing todo with it. This cache stores an abstract category tree.
This looks like this

#x#a:2:{s:6:"output";s:0:"";s:6:"result";s:322:"<option   value="12">Product attributes</option><option   value="11">Product variants</option><option   value="2">Product pattern</option><option   value="3">Pagination</option><option   value="4">Headpiece</option><option   value="7">Wear</option><option   value="9"> - Lady</option><option   value="8"> - Mister</option>";}


It has nothing todo with the search or filter by price. This cache is valid as long you do not change the categories. So as long you do not change your cats, this cache can be valid for months. It is only used by building a category tree, for example when you use the vm category module. It is also not a problem, that the cache reappears.

Quote from: Mayapi on February 18, 2016, 00:00:08 AM
I have check all modules cache and plugin page cache to NO.
Are you sure? There is an global option and an option per module.

Quote from: Mayapi on February 18, 2016, 00:00:08 AM
My question is: How is it posssible to remove the cache system of the "com_virtuemart_cats" ?

Your question to disable the cache has nothing todo with your problem

Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on February 18, 2016, 21:06:49 PM
Hum, milbo,
i don't want to pollemic, but i have new problems in last VM release, because session value in Model to do lazy loading.
SO as this is really good to add some caching, you should provide a way to disable cache and store some Session values.
Eg When you return now from a product in category , you return to the Same page(pagination), but my customer will return to first page and not saved pagination. I think (but don't tested) that is the same case when you come back from cart or any view other then category, the pagination stay, if you go in same category again. This is good when you want it so. But for lazy loading the page is always first page ,so i have to overide all only because this session values.

So as new features is cool, and thank you for this, i think it where better if we can use old methods too so you don't have to overide or hack the code to remove new changes doing your shop working another way from one to other release.

Title: Re: Category Cache Problem VM 3.0.8
Post by: Mayapi on February 19, 2016, 03:40:53 AM
@Milbo

after more intensive tests on all pages , i see you have right, the ajax problem of loading for the two modules seam working good, but not after my second menu.

Sorry about bad boggle !

Title: Re: Category Cache Problem VM 3.0.8
Post by: AnthonyWang on April 07, 2016, 20:07:40 PM
i have same problem,i temporary use jquery to fixed it,as Studio 42 said you should provide a way to disable cache and store some Session values. it's a best way
Title: Re: Category Cache Problem VM 3.0.8
Post by: AnthonyWang on April 08, 2016, 20:34:01 PM
Dear Studio42,today i tried your code on clean system and default templte,
but it's not works on joomla 3.5/VM 3.0.14
Title: Re: Category Cache Problem VM 3.0.8
Post by: Studio 42 on April 08, 2016, 23:30:38 PM
I think, it's a perhaps the router bug i found.
See http://forum.virtuemart.net/index.php?topic=133744.msg464009#msg464009
Sometime the category is not set(if you set category in the Joomla menu for eg.)
Title: Re: Category Cache Problem VM 3.0.8
Post by: ivacademyru on March 23, 2017, 16:25:15 PM
I Have the same problems with Joomla! 2.5.28 and VirtueMart 3.0.4. Somebody could reply if this cache problem is solved by VM team because for shop to keep working its necesary to clean  cache 2 times /day manualy?
Title: Re: Category Cache Problem VM 3.0.8
Post by: jenkinhill on March 23, 2017, 17:27:02 PM
I see no cache problems using current VirtueMart 3.2 and Joomla 3.6.5  (I don't have J2.5.x any more to test with).    http://forum.virtuemart.net/index.php?topic=118683

Test any updates on a backup copy of the live site.
Title: Re: Category Cache Problem VM 3.0.8
Post by: Milbo on March 23, 2017, 20:39:09 PM
The main problem was always, that FE and BE use different caches. So deleting the caches in the BE, did not deleted the FE caches. Now I understood this problem and caches are now always stored in the Frontend and properly cleared.