HighTechTalks DotNet Forums  

HttpHandling & Caching

ASP.net Caching microsoft.public.dotnet.framework.aspnet.caching


Discuss HttpHandling & Caching in the ASP.net Caching forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Francis
 
Posts: n/a

Default HttpHandling & Caching - 06-28-2005 , 05:12 PM






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.Add Seconds(60));
context.Response.Cache.SetSlidingExpiration(true);
context.Response.Cache.SetCacheability(HttpCacheab ility.Public);
context.Response.Cache.SetValidUntilExpires(true);

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.

Could anyone help?
Thanks
Francis

Reply With Quote
  #2  
Old   
Joerg Jooss
 
Posts: n/a

Default Re: HttpHandling & Caching - 07-01-2005 , 09:45 AM






Francis wrote:

Quote:
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.Add Seconds(60));
context.Response.Cache.SetSlidingExpiration(true);
context.Response.Cache.SetCacheability(HttpCacheab ility.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).

Quote:
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
mailto:news-reply (AT) joergjooss (DOT) de


Reply With Quote
  #3  
Old   
Francis
 
Posts: n/a

Default Re: HttpHandling & Caching - 07-01-2005 , 06:46 PM



Hi,
Thanks for your help. Sorry, I quickly entered that code here and put
60 seconds. I'll try it again with SetMaxAge() too.
Thanks for your help
Francis

Joerg Jooss wrote:
Quote:
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.Add Seconds(60));
context.Response.Cache.SetSlidingExpiration(true);
context.Response.Cache.SetCacheability(HttpCacheab ility.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).


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,

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.