I’ve a page that uses
The goal is to cache it for up to 24 hours, but I want it to specifically expire at midnight. Anyone know the trick?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
SetExpiresit takes aDateTimeand not a duration, so you don’t even need to calculate the number of seconds, just pass it whateverDateTimethe next midnight is going to be.