хендлер генерит картинку на диск,затем ее отдает
namespace psd
{
/// <summary>
/// Summary description for img
/// </summary>
public class img : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
var Params = context.Request.Params;
var notFoundPath = context.Server.MapPath("~/img/404.png");
if (Params["psd"] == null)
{
this.writeImage(notFoundPath);
return;
}
var psdPath = context.Server.MapPath("~/psd_files/" + Params["psd"]);
var imgOutPath = this.generateImageOutPath(Params["psd"], Params["text"]);
if (File.Exists(imgOutPath))
{
//context.Response.WriteFile(imgOutPath);
//context.Response.StatusCode = 304;
//context.Response.StatusCode = 304;
context.Response.Cache.SetExpires(DateTime.Now.AddMinutes(5));
context.Response.Cache.SetCacheability(HttpCacheability.Public);
//context.Response.Cache.SetValidUntilExpires(false);
this.writeImage(imgOutPath);
return;
}
else if (File.Exists(psdPath))
{
this.generateImage(psdPath, imgOutPath, Params["text"]);
//context.Response.WriteFile(imgOutPath);
this.writeImage(imgOutPath);
return;
}
else
{
this.writeImage(notFoundPath);
return;
}
}
public bool IsReusable
{
get
{
return true;
}
}
public void writeImage(String path)
{
HttpContext.Current.Response.ContentType = "image/png";
//HttpContext.Current.Response.AddHeader("content-disposition", "inline; filename=" + Path.GetFileName(path));
//HttpContext.Current.Response.StatusCode = 304;
// HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.Add(new TimeSpan(24, 0, 0)));
//HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);
//HttpContext.Current.Response.Cache.SetValidUntilExpires(false);
HttpContext.Current.Response.WriteFile(path);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
}
}
}
пытаюсь настроить кеширование,но не получается,гугление не помогло
менял заголовки,указывал статус код ответа 304,но не помогает
время повторной отдачи больше 1 секунды
сервак работает через cloudflare,по идее он должен кешировать статику
как исправить?