public async Task <IActionResult> Index(short id, string type, int page = 1, int pageSize = 1) { var link = HttpContext.Request.Path.Value; link = link + $"?type={type}&"; if (!_memoryCache.TryGetValue(type + id.ToString() + page.ToString(), out PaginationVm products)) { products = await _productClient.GetProductByFilter(id, type, page, pageSize); var cacheExpiryOptions = new MemoryCacheEntryOptions { AbsoluteExpiration = DateTime.Now.AddMinutes(5), Priority = CacheItemPriority.High, SlidingExpiration = TimeSpan.FromMinutes(2) }; _memoryCache.Set(type, products, cacheExpiryOptions); } int totalRecord = products.totalRecord; ViewData[Constants.PAGINATION_TOTALRECORD] = totalRecord; ViewData[Constants.PAGINATION_PAGESIZE] = pageSize; ViewData[Constants.PAGINATION_PAGE] = page; ViewData[Constants.PAGINATION_LINK] = link; ViewData[Constants.TYPE_BANNER] = type; ViewData[Constants.TYPE_BANNER_ID] = id; return(View("Index", products.productVms)); }