.NET MVC返回图片并通知浏览器进行缓存

public ActionResult Image()
{
string filePath = "D:\\123.png";
Response.Cache.SetExpires(DateTime.Now.AddDays(365)); // 缓存有效期为365天
Response.Cache.SetCacheability(HttpCacheability.Public); // 允许任何缓存服务器和浏览器进行缓存
Response.Cache.SetValidUntilExpires(true); // 缓存有效期由Expires头指定
return File(CommonHelper.GetImage(filePath), "image/png","123.png");
}

 

posted @ 2023-09-19 15:03  奇迹之耀  阅读(39)  评论(0编辑  收藏  举报