IIS7 - Client side caching a .ashx file that already has no-cache data set
In IIS7, I have a .ashx file from a third party which sets caching headers to be no-cache,private
I want this to be cached on the client so I have added the following code to the global.asax
void Application_EndRequest(object sender, EventArgs e)
{
if (Request.Path.IndexOf("Script.ashx") > -1)
{
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetExpires(DateTime.Now.AddDays(7));
Response.Cache.SetValidUntilExpires(true);
Response.Cache.VaryByHeaders["Accept-Language"] = true;
}
}
I would expect the resulting cache information to be public, Expires: Thu, 29 Sep 2011 开发者_运维百科16:06:27 GMT
Instead however I get the Franken-response of no-cache,public Expires: Thu, 29 Sep 2011 16:06:27 GMT
So the code is taking replacing the private with public as I want but it fails to replace the no-cache directive. Is it possible to replace the no-cache directive with this approach: if so what am I missing; if not what other approaches are there?
The above code fails in IIS7 Classic mode but the Integrated mode the code works as expected and produces sensible response headers. I assume this is due to the way that classic works similar to an ISAPI filter. I have switched to Integrated mode and this has solved the issue.
精彩评论