Hi everybody,
I have an ecommerce working in ASP.Net MVC. i'm using Caching to improve more performace in my pages and it's working fine.
I'd link to know what is more performative, for example, I can set OutPutCache in my views and and use this cache for all page OR I could get my List of Products in controller, put it on cache (like the code below) and send it to View to render for the user???
private IEnumerable<Products> GetProductsCache(string key, ProductType type)
{
if (HttpContext.Cache[key] == null)
HttpContext.Cache.Insert(key, ProductRepository.GetProducts(type), null, DateTime.Now.AddMinutes(10), Cache.NoSlidingExpiration);
return (IEnumerable<Products>)HttpContext.Cache[key];
}
public ActionResult Index()
{
var home = new HomeViewModel()
{
Products = GetProductsCache("ProductHomeCache", ProductType.Product)
Services = GetProductsCache("ServiceHomeCache", ProductType.Service)
};
return View(home);
}
Both works fine, but I'd like to know what is suggested to improve more performace ? Or is there others way to do it better ?
PS: sorry for my english!
thanks all...
Cheers