With OutputCache Duration what is the maximum amount of seconds you can use?

Posted on 2005-05-12
Medium Priority
Last Modified: 2008-01-09

Don't want to use the .NET data caching API for just one .aspx vb page, instead using

<%@ OutputCache Duration="xxx" VaryByParam="None" %>

where "xxx" is the duration in seconds.  Just wondering, can I make it a big number of seconds like 6000 so it'll stay in cache for 100 minutes or should it be limited just a handful of minutes.  At present I'm using 780 seconds.  W2003 Server has lots of memory.

Question by:raudi
LVL 25

Expert Comment

ID: 13993558
Usually this value is in seconds and will stay that long.  Visit the following URL:


HTH, Nauman.

Author Comment

ID: 13995584

I know that it is in seconds when using the @ OutputCache Duration and I can crank it up 780 seconds, I just wondered if there was a limit on the number of seconds because cause I want to cache just one page for over an hour.

Accepted Solution

ecc204 earned 1200 total points
ID: 14178856
The maximum value that you can set is not a static number.  It actually shrinks every second.  Here is the reason:

You can set the duration declaratively (using the @OutputCache directive) or programmatically.  The declarative page command will get translated into its programmatic equivalent which is as follows:


When you use a declarative command, you are actually saying: Response.Cache.SetExpires(DateTime.Now.AddSeconds((double)nSeconds));

The declaration for AddSeconds is public DateTime AddSeconds(double value).  But what is important is the fact that there is a maximum value for the DateTime value, and it is 12/31/9999 23:59:59.9999999.  So calculate the time left to that date in seconds and it is your number.  Note that as we go forward in time, that number shrinks.  That is so, because DateTime's maximum value is static.

So, you should be able to supply a number as big as a double.  But here is the concern: I do not know whether the people who wrote the ASP.net wrote it in a way to parse for such a large number out of your declarative statement.  To be safe I would go as high as an integer -- that is 2 to the power of 31.  If you want to do it programmatically, then use any date you wish on or before 12/31/9999 23:59:59.9999999.   That would go like this:

      Response.Cache.SetExpires(DateTime.Parse(“12/31/9999 23:59:59.9999999”));

      Or better yet


Lets hope there is no power outage by then. :)

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question