Post by fatihcr » Wed Nov 23, 2022 3:41 pm

Hello,

I'm using oc 3.0.3.8 and its a fresh install on a Litespeed server. The language and time zone is turkish.
I tried to use redis for caching, everything looks fine but bestseller and latest on homepage.
I want to explain everything first. Third party extensions works well on homepage, every product updates any changes like enable/disable products, stock status (even when someone buy it) etc.
But on bestseller and latest extensions, they does not update anything till the cache expire time. For example, i disable a product and it still showing on homepage/latest products like enabled.

Is this a general issue or just me?
Thanks in advance to anybody want to help.

Newbie

Posts

Joined
Fri May 18, 2012 6:16 am

Post by by mona » Wed Nov 23, 2022 3:52 pm


DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by fatihcr » Wed Nov 23, 2022 4:47 pm

by mona wrote:
Wed Nov 23, 2022 3:52 pm
what is caching https://nitropack.io/blog/post/web-cach ... ners-guide
Cache control headers viewtopic.php?t=214597
so you mean its about browser caching?
when i try with new secret chrome tab its same.
or when i turn redis to file cache its ok.

Newbie

Posts

Joined
Fri May 18, 2012 6:16 am

Post by by mona » Wed Nov 23, 2022 5:32 pm

Caching is in its basic form use an old file rather than a new one
the reason is to reduce the time it takes to get a webpage
the purpose is for you to speed up your site
the downside is it does not update

purge the cache after you have made an edit?
whether that be litespeed or anything else
I appreciate english is not your first language I am sure there are many blogs on the subject in turkish

I was just trying to get you to understand what it is your are installing - I am a advocate of doing everything else first.
Why do you need it ? If there is a reason you need it fix that.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by fatihcr » Wed Nov 23, 2022 5:59 pm

by mona wrote:
Wed Nov 23, 2022 5:32 pm
Caching is in its basic form use an old file rather than a new one
the reason is to reduce the time it takes to get a webpage
the purpose is for you to speed up your site
the downside is it does not update

purge the cache after you have made an edit?
whether that be litespeed or anything else
I appreciate english is not your first language I am sure there are many blogs on the subject in turkish

I was just trying to get you to understand what it is your are installing - I am a advocate of doing everything else first.
Why do you need it ? If there is a reason you need it fix that.
Thank you for help.
When the cache option is set to "file", everything works well as it should be.
My case is happening when i set it up to redis or memcached.
Both on redis or memcached, when someone buy a product which is 1 piece in stock, the latest or bestseller extensions is not updated on homepage. The product page is updated and shows no stock, search page, cateogry pages, everything is fine but these two extensions.
I've got the same result on different scenarios like i disable a product which is listing on bestseller. It's still showing up on bestseller but disabled on the other homepage extensions as normal.
I hope i can explained it correctly.

In the other hand, there's no information about this on turkish blogs or any other sources.

Newbie

Posts

Joined
Fri May 18, 2012 6:16 am

Post by ADD Creative » Wed Nov 23, 2022 6:57 pm

Looking at the code I can't see that the Redis cache ever worked correctly.
https://github.com/opencart/opencart/bl ... /redis.php

Redis del won't accept patterns so deleting 'products' won't remove 'product.latest...'.

You will need to stick with file cache, raise the issue on GitHub or get a developer to fix it.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by fatihcr » Wed Nov 23, 2022 8:25 pm

ADD Creative wrote:
Wed Nov 23, 2022 6:57 pm
Looking at the code I can't see that the Redis cache ever worked correctly.
https://github.com/opencart/opencart/bl ... /redis.php

Redis del won't accept patterns so deleting 'products' won't remove 'product.latest...'.

You will need to stick with file cache, raise the issue on GitHub or get a developer to fix it.
Thank you so much. I don't face this issue on only redis. Its same with memcached and litespeed cache extention.
I have researched it on every possible source on internet but can not see anything related. Am i the first complainer about this?
I just wonder that is it stable and fast enough for too many visitors on a starter pack server from digitalocean if i switch it to the file cache?
Is it possible to face some overconsumption on server in future?

Thank you in advance.

Newbie

Posts

Joined
Fri May 18, 2012 6:16 am

Post by ADD Creative » Thu Nov 24, 2022 1:01 am

The memcached cache will have the same issue as Redis. LiteSpeed is a different kind of cache that will be caching server responses. Unless it hooks onto events such as add product and automatically clears its cache they you could see a similar issue. As it's a third party extension you would have to ask LiteSpeed.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by fatihcr » Thu Nov 24, 2022 5:27 pm

when edit the lines below on catalog/model/catalog/product.php everything is ok
but is it elimate caching?

Code: Select all

public function getBestSellerProducts($limit) {
		$product_data = $this->cache->get('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit);

		if (!$product_data) {
			$product_data = array();

			$query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit);

			foreach ($query->rows as $result) {
				$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
			}

			$this->cache->set('product.bestseller.' . (int)$this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id') . '.' . $this->config->get('config_customer_group_id') . '.' . (int)$limit, $product_data);
		}

		return $product_data;
	}
to

Code: Select all

public function getBestSellerProducts($limit) {
			$product_data = array();

			$query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit);

			foreach ($query->rows as $result) {
				$product_data[$result['product_id']] = $this->getProduct($result['product_id']);
			}
		return $product_data;
	}

Newbie

Posts

Joined
Fri May 18, 2012 6:16 am

Post by paulfeakins » Thu Nov 24, 2022 6:05 pm

"There are only two hard things in Computer Science: cache invalidation and naming things."
-- Phil Karlton

For quick, professional OpenCart support please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - Reigate, Surrey, United Kingdom

Post by ADD Creative » Thu Nov 24, 2022 6:17 pm

fatihcr wrote:
Thu Nov 24, 2022 5:27 pm
when edit the lines below on catalog/model/catalog/product.php everything is ok
but is it elimate caching?
Yes, removing the cache get and set will remove the caching.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by fatihcr » Fri Nov 25, 2022 2:44 pm

https://github.com/opencart/opencart/issues/12030

i have opened up a github issue and the chairman closed it without any answer
i dont understand what i did wrong, i just need to fix it

Newbie

Posts

Joined
Fri May 18, 2012 6:16 am

Post by ADD Creative » Fri Nov 25, 2022 5:55 pm

Sadly this happens all the time with OpenCart. Real issues get closed for no reason and all manner of rubbish get merged.

You will probably have to stick with file cache and if you think it's causing a problem pay a developer to fix one of the others.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by straightlight » Fri Nov 25, 2022 10:23 pm

ADD Creative wrote:
Fri Nov 25, 2022 5:55 pm
Sadly this happens all the time with OpenCart. Real issues get closed for no reason and all manner of rubbish get merged.

You will probably have to stick with file cache and if you think it's causing a problem pay a developer to fix one of the others.
Not sure where these analysis are taken from, but one thing's for sure is that I don't see any pull requests in the opencart-3 repository in regard of cache issues especially since the OP user is using OC v3.x releases.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by by mona » Fri Nov 25, 2022 11:39 pm

For redis you could try changing this:

Code: Select all

	public function delete($key) {
		$this->cache->del(CACHE_PREFIX . $key);
	} 
to this:

Code: Select all

	public function delete($key) {
		$this->cache->del($this->cache->keys(CACHE_PREFIX . $key.'*');
	} 

Be aware that using the keys() method has implications performance-wise.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am
Who is online

Users browsing this forum: No registered users and 23 guests