The page will expire using outputcache varybyparam = "*" at a specific time

I have a page that uses

The goal is to cache it for up to 24 hours, but I want it to expire at midnight. Does anyone know a trick?

0


a source to share


1 answer


You can calculate the number of seconds until midnight each time the page loads, and then programmatically set the duration with Response.Cache.SetExpires

. I've never done this, but I don't understand why it won't work.

Obviously it's midnight on the server, you probably don't know what time of day it is on the client.



EDIT. Actually looking at the definition SetExpires

it takes DateTime

, not the duration, so you don't even need to calculate the number of seconds, just pass it regardless DateTime

at the next midnight.

+3


a source







All Articles