Caching page for 24hours

Hi, i want my content to be refresh every day at midnight, so i would cache for 24hours. but my problem is, if i use this command here:

<%@ OutputCache VaryByParam="none"  Duration="86400"%>

it will cash for 24hours but will not refresh at midnight. How can i accomplish this.
Who is Participating?
suvmitraConnect With a Mentor Commented:
HTTP/1.1 200 OK
Date: Fri, 30 Oct 1998 13:19:41 GMT
Server: Apache/1.3.3 (Unix)
Cache-Control: max-age=3600, must-revalidate
Expires: Fri, 30 Oct 1998 14:19:41 GMT
Last-Modified: Mon, 29 Jun 1998 02:28:12 GMT
ETag: "3e86-410-3596fbbc"
Content-Length: 1040
Content-Type: text/html

Open in new window

if you want to implement something similar to this you may need to look for a detail discussion @

Check the documents in detail.

You can callback with HttpRuntime.Cache.

or may be try a different approach like using timer,

protected void Application_Start()
    Timer customTimer = new Timer();
    customTimer.Elapsed += new ElapsedEventHandler(YourHandler.YourRepopulationEvent);
    customTimer.Interval = YourInterval;
rafaelrglAuthor Commented:
the way you show above will apply to my aplication, not just one webusercontrol, that code is inside an webusercontrol. So, is there anyway to mark expiration date, then when expire mark again.
Try this....

<% DateTime dte = DateTime.Now; %>
<meta http-equiv="refresh" content="<%=86400 - (((dte.Hour * 60) + dte.Minute) * 60) %>">
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.