I've got an ASP.NET MVC method (v3.0 on .NET 4.0) set up like the following:
[OutputCache(Duration = 31536000, Location = OutputCacheLocation.Any)]
public virtual ActionResult Item()
{
this.Response.Cache.SetLastModified(new DateTime(2011, 01, 01));
return this.Content("hello world", "text/plain");
}
I'd expect this to come back with the Last-Modified
header set to Mon, 07 Feb 2011 00:00:00 GMT
as specified, however it is actually coming back as the date that the output was first cached in the output cache (i.e. the first time the method was called since IIS was reset).
If I comment out the [OutputCache]
attribute so that no output caching is done then the Last-Modified
header comes back as expected, so it appears that it's something in the output caching infrastructure that's choosing to ignore my specified value for this.
Any idea why it might be doing so? And is there any way to make it use my specified value as the Last-Modified
date?