Reputation: 10756
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?
Upvotes: 0
Views: 834
Reputation: 10756
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.
Upvotes: 1