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

Posted on 2005-05-12
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

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

    HTH, Nauman.

    Author Comment


    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.
    LVL 4

    Accepted Solution

    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 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. :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now