Caching and Site speed on NopCommernce

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
10 years ago
Hi All,

I'm testing some changes on my site at the moment.  The ProductLoadAllPaged seems to be the biggest culprit for slowing the site response.

Anyway I've added some webcaching to that call, and getting some better repsonses.
Let me know if you thing the site is quicker, I can share the code.

the site is http://www.lovekidsbooks.com
10 years ago
Sure, please share your code
10 years ago
feelyd wrote:

Anyway I've added some webcaching to that call, and getting some better repsonses.


What type of webcaching have you implemented?
10 years ago
I changed the CatalogController.cs, You need to locate the following method

......

public ActionResult Category(int categoryId, CatalogPagingFilteringModel command)
        {
....

Replace the call

IPagedList<Product> products = _productService.SearchProducts(categoryIds, 0,
                _catalogSettings.IncludeFeaturedProductsInNormalLists ? null : (bool?)false,
                minPriceConverted, maxPriceConverted,
                0, string.Empty, false, false, _workContext.WorkingLanguage.Id, alreadyFilteredSpecOptionIds,
                (ProductSortingEnum)command.OrderBy, command.PageNumber - 1, command.PageSize,
                true, out filterableSpecificationAttributeOptionIds);


With

.....

// Create the caching key
            string cachingKey = string.Empty;
            foreach (int i in categoryIds)
            {
                cachingKey += i.ToString() + "_" ;
            }

            foreach (int i in alreadyFilteredSpecOptionIds)
            {
                cachingKey += i.ToString() + "_";
            }

            cachingKey += _catalogSettings.IncludeFeaturedProductsInNormalLists ? null : (bool?)false
                + "_" + minPriceConverted
                + "_" + maxPriceConverted
                + "_" + _workContext.WorkingLanguage.Id
                + "_" + command.OrderBy
                + "_" + command.PageNumber
                + "_" + command.PageSize;
            //

            IPagedList<Product> products = _cacheManager.Get<IPagedList<Product>>(cachingKey);

            if (products == null)
            {
                products = _productService.SearchProducts(categoryIds, 0,
                _catalogSettings.IncludeFeaturedProductsInNormalLists ? null : (bool?)false,
                minPriceConverted, maxPriceConverted,
                0, string.Empty, false, false, _workContext.WorkingLanguage.Id, alreadyFilteredSpecOptionIds,
                (ProductSortingEnum)command.OrderBy, command.PageNumber - 1, command.PageSize,
                true, out filterableSpecificationAttributeOptionIds);

                _cacheManager.Set(cachingKey, products, 5000);

            }
10 years ago
This is a rough draft, but for a site with a fair bit of traffic you hopefully should see some noticeable improvements.

I've set the cache time to 5000, you should make this configurable.
10 years ago
I do not recommend applying this change. EF does not support second-level caching. It can cause a lot of internal issues.

P.S. Otherwise we did not long time ago
10 years ago
You can read this also: https://www.nopcommerce.com/boards/t/24544/how-to-improve-performance-for-nopcommerce-30.aspx#100652
10 years ago
a.m. wrote:
I do not recommend applying this change. EF does not support second-level caching. It can cause a lot of internal issues.

P.S. Otherwise we did not long time ago

Could you please point me to information on caching that does work then please, like for example output caching?
5 years ago
feelyd wrote:
Hi All,
😂😍❤👍😁🙌🤦‍♀️🤦‍♀️😎✌🤷‍♂️😁😁
I'm testing some changes on my site at the moment.  The ProductLoadAllPaged seems to be the biggest culprit for slowing the site response.

Anyway I've added some webcaching to that call, and getting some better repsonses.
Let me know if you thing the site is quicker, I can share the code.

the site is http://www.lovekidsbooks.com
5 years ago
feelyd wrote:
Hi All,

I'm testing some changes on my site at the moment.  The ProductLoadAllPaged seems to be the biggest culprit for slowing the site response.

Anyway I've added some webcaching to that call, and getting some better repsonses.
Let me know if you thing the site is quicker, I can share the code.

the site is http://www.lovekidsbooks.com


Wow. THis page load so fast... Topic is from 2013 year. Andrei is something change, and now it's possible to implement this? Damn google insight show server answer 0,33 s... our page on azure 1,2 - 1,5 s... someone test this?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.