UPDATE: 2011-03-14 La correzione è garantire si chiama SetSlidingExpiration (vero)
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Cache.SetMaxAge(TimeSpan.FromMinutes(5));
context.Response.ContentType = "image/jpeg";
context.Response.Cache.SetSlidingExpiration(true);
Se si rimuove il modulo OutputCache si vuole ottieni il risultato desiderato Lo vedo come un insetto.
Così, nel web.config si dovrebbe effettuare le seguenti operazioni:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="OutputCache"/>
</modules>
</system.webServer>
aggiunto: so, ci sono ulteriori informazioni.
- Uso OutputCacheAttribute di MVC apparentemente non ha questo problema
- Sotto la stessa applicazione MVC, senza rimuovere "OutputCache" dai moduli, un'implementazione diretta se IHttpHandler o un ActionResult risultati nel s-MaxAge essendo spogliato
il seguente spoglia il s-MaxAge
public void ProcessRequest(HttpContext context)
{
using (var image = ImageUtil.RenderImage("called from IHttpHandler direct", 5, DateTime.Now))
{
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Cache.SetMaxAge(TimeSpan.FromMinutes(5));
context.Response.ContentType = "image/jpeg";
image.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}
}
il seguente spoglia il s-MaxAge
public ActionResult Image2()
{
MemoryStream oStream = new MemoryStream();
using (Bitmap obmp = ImageUtil.RenderImage("Respone.Cache.Setxx calls", 5, DateTime.Now))
{
obmp.Save(oStream, ImageFormat.Jpeg);
oStream.Position = 0;
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetMaxAge(TimeSpan.FromMinutes(5));
return new FileStreamResult(oStream, "image/jpeg");
}
}
Questo non significa - vai a capire ...
[OutputCache(Location = OutputCacheLocation.Any, Duration = 300)]
public ActionResult Image1()
{
MemoryStream oStream = new MemoryStream();
using (Bitmap obmp = ImageUtil.RenderImage("called with OutputCacheAttribute", 5, DateTime.Now))
{
obmp.Save(oStream, ImageFormat.Jpeg);
oStream.Position = 0;
return new FileStreamResult(oStream, "image/jpeg");
}
}