Hi,
I don't know if any of you guys managed to sort this cache problem out. I had the same problem last week. I made a template for nopcommerce which I am selling
here.
Now the problem is that I have only added banners to the system and everything else is same except I am using ajax/jquery a lot using the same methods so that shouldn't matter on the speed. By the way I am using nop 1.9. Every thing was working fine until one of the customer upload around 1000 products which is not a lot in fact nothing and it shouldn't matter but the system was taking around 8/10 seconds to load each page. I started looking into it and implemented NopStaticCache then I got that duplicate error that entity already exist so you can't attach it in all the update methods.
The work around to that problem is to declare a the entity in the update and get from cache, such as this is category update method;
public void UpdateCategory(Category categoryRequested)
{
if (categoryRequested == null)
throw new ArgumentNullException("category");
Category category = _context.Categories.SingleOrDefault(x => x.CategoryId == categoryRequested.CategoryId);
if (category == null)
throw new ArgumentNullException("category");
category.Name = categoryRequested.Name;
category.Description = categoryRequested.Description;
category.TemplateId = categoryRequested.TemplateId;
category.MetaKeywords = categoryRequested.MetaKeywords;
category.MetaDescription = categoryRequested.MetaDescription;
category.MetaTitle = categoryRequested.MetaTitle;
category.SEName = categoryRequested.SEName;
category.ParentCategoryId = categoryRequested.ParentCategoryId;
category.PictureId = categoryRequested.PictureId;
category.PageSize = categoryRequested.PageSize;
category.PriceRanges = categoryRequested.PriceRanges;
category.ShowOnHomePage = categoryRequested.ShowOnHomePage;
category.Published = categoryRequested.Published;
category.Deleted = categoryRequested.Deleted;
category.DisplayOrder = categoryRequested.DisplayOrder;
category.CreatedOn = categoryRequested.CreatedOn;
category.UpdatedOn = categoryRequested.UpdatedOn;
category.ShowOnMenu = categoryRequested.ShowOnMenu;
category.Name = CommonHelper.EnsureNotNull(category.Name);
category.Name = CommonHelper.EnsureMaximumLength(category.Name, 400);
category.Description = CommonHelper.EnsureNotNull(category.Description);
category.MetaKeywords = CommonHelper.EnsureNotNull(category.MetaKeywords);
category.MetaKeywords = CommonHelper.EnsureMaximumLength(category.MetaKeywords, 400);
category.MetaDescription = CommonHelper.EnsureNotNull(category.MetaDescription);
category.MetaDescription = CommonHelper.EnsureMaximumLength(category.MetaDescription, 4000);
category.MetaTitle = CommonHelper.EnsureNotNull(category.MetaTitle);
category.MetaTitle = CommonHelper.EnsureMaximumLength(category.MetaTitle, 400);
category.SEName = CommonHelper.EnsureNotNull(category.SEName);
category.SEName = CommonHelper.EnsureMaximumLength(category.SEName, 100);
category.PriceRanges = CommonHelper.EnsureNotNull(category.PriceRanges);
category.PriceRanges = CommonHelper.EnsureMaximumLength(category.PriceRanges, 400);
//validate category hierarchy
var parentCategory = GetCategoryById(category.ParentCategoryId);
while (parentCategory != null)
{
if (category.CategoryId == parentCategory.CategoryId)
{
category.ParentCategoryId = 0;
break;
}
parentCategory = GetCategoryById(parentCategory.ParentCategoryId);
}
if (!_context.IsAttached(category))
_context.Categories.Attach(category);
_context.SaveChanges();
if (this.CategoriesCacheEnabled || this.MappingsCacheEnabled)
{
NopStaticCache.RemoveByPattern(CATEGORIES_PATTERN_KEY);
NopStaticCache.RemoveByPattern(PRODUCTCATEGORIES_PATTERN_KEY);
}
}
Update all update routines and this solves the problem of using NopStaticCache. Then there was another problem of w3wp process going up to 600mb and website throwing out of memory exception. The work around is to restrict w3wp to whatever you want, I restricted it to use 200mb and the website was working fine. Now if the process goes over 200mb IIS recycles it and doesn't make any difference on the website as It doesn't recycle the process completely, only so it don't go over 200mb or whatever limit you have.
Please have a look at
http://www.wholesalecontractfurniture.com/manufacturer/6-woodardfurniture.aspx, this page is loading 578 records using the famous loadallpagedproducts procedure and it works like a charm.
Regards,
Atiq