【发布时间】:2013-07-23 13:01:58
【问题描述】:
我有用于图像的 IHttp 通用处理程序 (.ashx),我已发送缓存过期时间为 7 天,但在 Google 页面洞察力中它说我应该添加缓存验证器。 以下是我的代码。请给我一些参考。
public void ProcessRequest(HttpContext context)
{
TimeSpan refresh = TimeSpan.FromDays(7);
context.Response.Cache.SetExpires(DateTime.Now.Add(refresh));
context.Response.Cache.SetMaxAge(refresh);
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.CacheControl = HttpCacheability.Public.ToString();
context.Response.Cache.SetValidUntilExpires(true);
}
谢谢
【问题讨论】:
标签: asp.net-mvc-3 caching httpcontext ihttphandler generic-handler