I have an ASP.NET MVC method (v3.0 on .NET 4.0) configured as follows:
[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 would expect this to return with the Last-Modified header set to Mon, 07 Feb 2011 00:00:00 GMT , as indicated, however it does return as the date the output was first cached in the output cache (i.e. .the first time the method was called because IIS was reset).
If I comment on the [OutputCache] attribute so that output caching is not completed, the Last-Modified header will return as expected, so it seems to be something in the output caching infrastructure that decided to ignore my specified value for this.
Any idea why this could be so? And is it possible to use its specified value as the Last-Modified date?
source share