[quoted text, click to view] Francis wrote:
> Hi everyone,
> I have a page that is being requested from an http handler in the
> web.config file. I am trying to get this to cache so it just executes
> the code every half hour. I have tried programatically, but it
> doesn't seem to work at all, I tried with the following simple code:
>
> context.Response.Write( DateTime.Now );
> context.Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
> context.Response.Cache.SetSlidingExpiration(true);
> context.Response.Cache.SetCacheability(HttpCacheability.Public);
> context.Response.Cache.SetValidUntilExpires(true);
Two remarks:
-- This keeps your response only fresh for 60 seconds -- but you wanted
30 minutes?
-- It's better to use SetMaxAge(), as it specifies freshness in
relative time instead of absolute as SetExpires() does (unless you're
serving to HTTP 1.0 clients, which don't understand max-age).
[quoted text, click to view] > Every time the page is executed, the date updates regardless. I have
> tried writing the date at the bottom of this code too, just in case.
That's weird; if I put your code in a simple web form, it is cached for
60 seconds as expected. Are you sure that the client isn't the culprit?
Cheers,
--
http://www.joergjooss.de