nopCommerce
nopCommerce copied to clipboard
Slow loading when Categoryview has products that contain complex content
nopCommerce version: 4.4+
Steps to reproduce the problem:
- Enable paste image in Tinymce
Open file Nop.Web\Areas\Admin\Views\Shared\EditorTemplates\RichEditor.cshtml and delete paragraph
paste@(enableFullPage ? " fullpage" : null)
- Create a new product with product name is "HPE ProLiant DL380 Gen10 Server", Full description content copied from https://h20195.www2.hpe.com/v2/gethtml.aspx?docname=a00008180enw Expand all and copy all in red
- Categories I chose Computer>Desktops
- Save product
RESULT
After enable miniprofiler, I go to the public store, then open link category Desktops, I refresh the web several times
- On nopCommerce 4.4, the average speed is 9000ms
- I do the same with nopCommerce 4.3, the average speed is 105ms
Also on nopCommerce 4.4, at Admin> Catalog> Product page, when I search for products in category Desktops, the results are loaded very slowly.
I tried over and over again, even just downloading the original on github then running nopCommerce on localhost, but the result is the same as above
Here are two results I got from miniprofiler:
Catalog_Category (9191.8 ms) - Profiling Results nopCommerce 4.4.pdf Catalog_Category (104.5 ms) - Profiling Results nopCommerce 4.3.pdf
I’m guessing because the ‘ PrepareProductOverviewModelsAsync’ in ProductModelFactory pulls the full description as well as the short description?
I see nop 4.3 also has a full description but web performance has changed on the new version.
During use, I found that many other pages also had performance affected by this.
I see a line of code:
//little performance optimization: ensure that "FullDescription" is not returned
productModel.FullDescription = string.Empty;
Whether there is a temporary solution for this, I have no need to use full descripion on categoryview or homepage
Comment out https://github.com/nopSolutions/nopCommerce/blob/a298e6a29fd0cc130257afdca8f44bd4752cfead/src/Presentation/Nop.Web/Factories/ProductModelFactory.cs#L1215 and test.
One of my clients doesn't use short or full descriptions, so we comment both of these out for them.
Comment out https://github.com/nopSolutions/nopCommerce/blob/a298e6a29fd0cc130257afdca8f44bd4752cfead/src/Presentation/Nop.Web/Factories/ProductModelFactory.cs#L1215 and test.
One of my clients doesn't use short or full descriptions, so we comment both of these out for them.
This doesn't solve the problem
I think the problem is related to Async https://github.com/dotnet/ef6/issues/88
The performance seems to be slow in loading speed whenever there is an action that calls this product, such as: Search autocomplete, homepage product.
I tried this on PostgreSQL and it works great
This problem only occurs with Sql Server. https://github.com/dotnet/SqlClient/issues/593
Since the issue is in SqlClient we not able to fix it now. There is only one workaround: switching to non-async API for problematic methods, but we leave it for customizing, because it happens under quite specific conditions.