1
我有代碼緩存MVC操作中的圖像,但我不明白什麼是真正需要和什麼是多餘的。你能否檢查一下並告訴我你的意見?檢查緩存圖像代碼
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetExpires(DateTime.Now.AddSeconds(ApplicationSettings.CacheDuration));
Response.AppendHeader("Content-Length", imageContent.Length.ToString());
Response.Cache.VaryByParams.IgnoreParams = true;
Response.Cache.VaryByParams["*"] = true;
Response.Cache.SetValidUntilExpires(false);
Response.Cache.SetMaxAge(new TimeSpan(0, 0, ApplicationSettings.CacheDuration));
Response.AddHeader("content-disposition", string.Format("inline; filename={0}", fileName));
Response.OutputStream.Write(imageContent, 0, imageContent.Length);
Response.Flush();
return File(imageContent, contentType);