Page 1 of 1

Slow Open Cart Store Because of Category Data Processing

Posted: Fri Jun 06, 2014 9:58 am
by hcamelion
??? Hi,

This is not exactly a bug but it is a performance issue for stores with lots of categories.

We have a store here: http://www.lynallan.com/

We have a lot of categories in the top menu and also on sub category pages in the right sidebar. We were seeing server side and client side total page load times of 15-30 seconds. Server side the home page was seeing 6-15 seconds and the sub cat pages were seeing 12-25 seconds and this is all server side before the client side even gets the page. Then client side time was an additional 3-8 seconds.

I used a benchmark class and first thing I noticed was 900 queries being run. Most of them were calling $this->url->link.

I finally narrowed it down to the category data processing in these locations:

foreach ($categories as $category) in catalog/controller/module/category.php around line 33

foreach ($categories as $category in catalog/controller/common/header.php around line 107


My question is why isn't this category data cached?

I have now cached it via a vqmod. I have attached it if anyone else wants it.

My only other question remaining is I would like to know if there is a cache time setting in the admin and if not how long is data cached?

Let me know what you think of this?

Download it on Github: https://gist.github.com/weismannweb/a16 ... 89ca1d1209

EDIT: Updated to work with multi-store. Thanks to platoon for multi-store fix.

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Sat Jun 07, 2014 2:42 am
by rph
Cache files expire in 60 minutes. Unfortunately there's no way to change the value within OpenCart as of 1.5.x short of modifying the core (that will change in 2.0). You'll have to edit /system/library/cache.php to increase it.

Also check that the url_alias table has query and keyword indexed. It can provide a good speed bump though the sheer number of queries will still be a drag.

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Sat Jun 28, 2014 4:50 am
by tobychin
Henry,
Your VQMod is a lifesaver! I have been trying to get the number of SQL queries on a site we're hosting (number of queries was almost 700 for the home page) and this did the trick. Server response time was over 18 seconds, and is now down to under 200 ms. Thank you, thank you, thank you! Anyone else experience slow load times and already have the product count turned off: you definitely need to try this!

Q / Daniel,
Please consider integrating something like this into the core. This was such a problem for us that we were considering not using OpenCart as a platform any longer. I no longer feel as though I have to immediately shy people away from considering the OpenCart platform.

RPH,
While I understand that the indexing can help, site owners shouldn't have to go in to PHPMyAdmin and ensure that these columns are indexed...

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Sat Jun 28, 2014 5:37 am
by IP_CAM
tobychin wrote:Henry, Your VQMod is a lifesaver!
read this post as well, you may find more speed-idea's:

http://forum.opencart.com/viewtopic.php?f=10&t=127322

Ernie

ipc.li/shop/

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Wed Jul 30, 2014 6:51 pm
by paynechia
Hi Hcamelion,

My site is running in 2 languages. The category cache doesn't work when I change to another language. Is it possible to get this cache to support multi-language site?

Thank you~

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Fri Aug 22, 2014 1:10 am
by IP_CAM
paynechia wrote:My site is running in 2 languages. The category cache doesn't work when I change to another language. Is it possible to get this cache to support multi-language site?
since you got no reply, let me do it:

If you have any caching active in your 'header' Files, category-selection will possibly not change languages, I had a similar effect.
But the Content should change anyway to the other language, but it probably depends as well on what kind of caching method you use.

Ernie

openshop.li

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Fri Aug 22, 2014 10:46 pm
by yavenay
OMG this worked. My site is now lightning fast. :D :D :D :D :D

Thank you so much.

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Sun Oct 26, 2014 4:51 pm
by platoon
hcamelion wrote: This is not exactly a bug but it is a performance issue for stores with lots of categories.
It is not an issue anymore after i found your life saver post :)
In addition, it is also good to have multistore support which is achieved with couple small changes. Small improvement to your already perfect mod attached.

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Sat Dec 20, 2014 10:36 am
by hcamelion
Im sorry for not responding to the posts that have been made since I created this post. For some reason even though I am subscribed I am not getting notifications of new posts.

Thanks platoon for your contribution...I have updated my file in case nobody scrolls and reads further. Also paynechia let us know if you resolved your problem?

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Sat Dec 20, 2014 11:14 am
by IP_CAM
Just to inform about another Cache Option:
http://forum.opencart.com/viewtopic.php ... e&start=20

Ernie
ipc.li

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Tue Feb 17, 2015 11:14 pm
by IP_CAM
Customers will be happy not to have to click, just to find empty Pages!! They do this twice, then, they leave for good.

I hardcoded BOTH MOD's in Discussion, but not the Page-Cache Mod, mentioned in my last Post above, here into the Source. Testing the setup with activated Page-Cache, it 'fixed' my Page-Load Value to the (cached) Value, when cashing the Page, so, I was unable to get any more 'actual' results...

I enclosed ALL (Category-Cache related) 3 modified Source files in a ZIP. Avoid's more VqMod Server Templates to be built... (suitable OC v.1.5.6.1-5) For SUCH TASKS, I would NEVER use VqMods, just to mentioned it. I seek Speed, without compromises...

Good Luck
Ernie
ipc.li/shop/

PS: Please DO NOT ask questions, if it does not work. It's just meant for Coders, not Newbie's...

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Wed Jul 15, 2015 4:12 pm
by Concept211
Really great job on this vQmod, @hcamelion! Many, many thanks...worked like a charm on v1.5.6.4!

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Sun Nov 22, 2015 8:38 pm
by dkgawande
Thanks for the vqmod. I have two questions
1. Are these changes now part of latest opencart version (2.1) released on 6th Oct 2015?
2. How can I apply this vqmod to my store?

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Wed Jun 22, 2016 11:45 pm
by mworsnop
Sorru I am new to OC. How do I install the mod and will it work with 2.1

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Thu Jun 23, 2016 9:04 am
by IP_CAM
No, they both won't work!
Ernie

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Thu Jun 23, 2016 9:25 pm
by celia1980
I have the same problem to open cart :-\

Re: Slow Open Cart Store Because of Category Data Processing

Posted: Thu Jul 19, 2018 3:36 am
by IP_CAM
Latest Extension for OC v.3.0.x Versions, possibly works on late v.2.3.x Versions too:
cache_category_data.xml
https://gist.github.com/weismannweb/8ad ... 8d751281b2
Ernie
---