Hi Anil,
This is what I do in the application code.
A typical request is http://mysite/get-image.img?path=test.png&width=240&height=320&format=jpg&tag=xyz&expire=365
Within “get-image.img” code, I have this:
HttpCachePolicy cachePolicy = HttpContext.Current.Response.Cache;
cachePolicy.SetCacheability(HttpCacheability.Public);
cachePolicy.SetExpires(DateTime.Now.AddDays(expireDays));
cachePolicy.SetValidUntilExpires(true);
I checked the server response (prior to caching), and I do see the “expire” header being sent:
Expires: Fri, 16 Jul 2010 09:00:06 GMT
From the IIS manager / Output Caching, I added a custom extension “.img” (to match my get-image.img HttpHandler), with the following configuration:
-
User-Mode caching : At time intervals (6 hours)
-
Kernel-Mode caching : At time intervals (6 hours)
Not sure why the kernel mode doesn’t require to set query string variable, but I tried this with User-Mode alone, or Kernel-Mode alone, and it didn’t fix my problem (another question, by the way, how can both modes be activated at the same time? Does one take precedence over the other?).
So after a few request of the same URL, the response content gets cached, but when looking at the response, it’s missing the “expire” header. What should I do so that the header is also sent by the output caching?
Best,
Thierry