I am trying to enable output caching for all ashx files on my site. I am trying to get the server to generate a file for every request - DO NOT try to tell the browser to cache the file.
I overtook my ashx file to this simple code:
public class DefaultStyles : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/css"; StringBuilder styleSheet = new StringBuilder(); styleSheet.AppendLine(string.Format("/* Generated: {0}, {1} */", DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString())); context.Response.Write(styleSheet.ToString()); } }
And in my web.config file, I have this:
<system.webserver> <caching enabled="true"> <profiles> <add extension=".ashx" policy="CacheForTimePeriod" duration="00:01:00" /> </profiles> </caching> </system.webserver>
However, every request I make to the ashx file generates a new version with the current date and time in it.
What am I doing wrong?
Thanks.
source share