Link to home
Start Free TrialLog in
Avatar of rafaelrgl
rafaelrgl

asked on

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.
Avatar of suvmitra
suvmitra
Flag of India image

Hi,

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;
    customTimer.Start();
}
Avatar of rafaelrgl
rafaelrgl

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of suvmitra
suvmitra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sara bhai
Try this....

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