Caching with ASP.NET, can I use page directive programmatically

Discussion in 'ASP .Net' started by Leo Muller, Nov 14, 2004.

  1. Leo Muller

    Leo Muller Guest

    I am impressed by the caching performance of .NET. However, there is one
    major obstacle that I haven't managed to solve yet.

    What I want to do is the following: I have a normal site, and a preview
    site. The normal site should have maximum performance, thus uses caching.
    The preview site is for internal use only, and should not use caching, since
    our content managers will want to see the updates directly. The only
    difference between the two sites is the web.config file.

    If I use caching programmatically, then everything works out great, I add a
    key in the webconfig, and only if this is the normal site then it will do
    caching, otherwise it won't.
    But if I use the caching through the page directives, <@OutputCache
    Duration="300" VaryByParam="none"%>, then I can't vary this anymore between
    my preview site and my normal site.

    How can I overcome this problem?

    Leo Muller
     
    Leo Muller, Nov 14, 2004
    #1
    1. Advertising

  2. Leo Muller

    Karl Seguin Guest

    You can use the Response.Cache object to do it programatically....

    For example:
    Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
    Response.Cache.SetCacheability(HttpCacheability.Public);
    Response.Cache.SetValidUntilExpires(true);
    Response.Cache.VaryByParams.IgnoreParams = true;

    http://msdn.microsoft.com/library/d...guide/html/cpconsettingcacheabilityofpage.asp

    Karl
    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Leo Muller" <> wrote in message
    news:cn6vdt$l9c$...
    > I am impressed by the caching performance of .NET. However, there is one
    > major obstacle that I haven't managed to solve yet.
    >
    > What I want to do is the following: I have a normal site, and a preview
    > site. The normal site should have maximum performance, thus uses caching.
    > The preview site is for internal use only, and should not use caching,

    since
    > our content managers will want to see the updates directly. The only
    > difference between the two sites is the web.config file.
    >
    > If I use caching programmatically, then everything works out great, I add

    a
    > key in the webconfig, and only if this is the normal site then it will do
    > caching, otherwise it won't.
    > But if I use the caching through the page directives, <@OutputCache
    > Duration="300" VaryByParam="none"%>, then I can't vary this anymore

    between
    > my preview site and my normal site.
    >
    > How can I overcome this problem?
    >
    > Leo Muller
    >
    >
     
    Karl Seguin, Nov 14, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. psb
    Replies:
    0
    Views:
    1,666
  2. Troy Simpson

    Fragment Caching inside page caching?

    Troy Simpson, Jan 19, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    815
    Troy Simpson
    Jan 19, 2004
  3. JimLad
    Replies:
    3
    Views:
    933
    JimLad
    Jan 21, 2010
  4. Arnaud PICHERY

    Adding a Register directive to an aspx page programmatically

    Arnaud PICHERY, Nov 16, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    392
    Teemu Keiski
    Nov 18, 2003
  5. Arnaud PICHERY
    Replies:
    0
    Views:
    160
    Arnaud PICHERY
    Nov 14, 2003
Loading...

Share This Page