Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Caching / July 2005

Tip: Looking for answers? Try searching our database.

HttpHandling & Caching

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Francis - 28 Jun 2005 22:12 GMT
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);

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
Joerg Jooss - 01 Jul 2005 14:45 GMT
> Hi everyone,
>     I have a page that is being requested from an http handler in the
[quoted text clipped - 7 lines]
> 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).

> 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,
Signature

http://www.joergjooss.de
mailto:news-reply@joergjooss.de

Francis - 01 Jul 2005 23:46 GMT
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

>>Hi everyone,
>>    I have a page that is being requested from an http handler in the
[quoted text clipped - 24 lines]
>
> Cheers,

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.