I've a page that uses
<%@ outputcache duration="8640" varybyparam="*" %>
The goal is to cache it for up to 24 hours, but I want it to specifically expire at midnight. Anyone know the trick?
I've a page that uses
<%@ outputcache duration="8640" varybyparam="*" %>
The goal is to cache it for up to 24 hours, but I want it to specifically expire at midnight. Anyone know the trick?
You could calculate the number of seconds to midnight every time the page is loaded, then programatically set the duration using Response.Cache.SetExpires
. I've never done it, but I don't see why it wouldn't work.
Obviously, this is midnight on the server, you probably have no idea what time of day it is on the client.
EDIT. Actually, looking at the defintion of SetExpires
it takes a DateTime
and not a duration, so you don't even need to calculate the number of seconds, just pass it whatever DateTime
the next midnight is going to be.