Cache VaryByParam problems

Discussion in 'ASP .Net' started by João Maia, Jul 2, 2008.

  1. João Maia

    João Maia Guest

    Hello there,

    I'm using Cache VaryByParam on a page and I'm not getting the
    behaviour I expected. Here's what happens:

    - I have page a.aspx declared with Cache VaryByParam="name"
    - Page a.aspx has a label in which I set the time the page was
    retireved by using DateTime.Now() on the server side (just to what
    version of the page I'm getting, and if the cache is working)
    - My requests to page a.aspx are generated in other pages, and usually
    have more than one query string parameter, but the parameter "name" is
    always there. For example,

    "http://someserver.com/a.aspx?name=john&age=30", or
    "http://someserver.com/a.aspx?name=john&age=30&city=lisbon" or
    "http://someserver.com/a.aspx?city=30&name=john"

    What I was expecting is that, when parameter "name" is "john", a.aspx
    would be retrieved from the cache regardless of the values of the
    other parameters. When the parameter "name" would change to "mary"
    then a new version of a.aspx should be retrieved from the server
    instead of from cache.

    What's happening instead is that the page is ALWAYS retrieved from
    cache (I can say that because of the datetime label I have on the
    page), regardless of the value of query string parameter "name".

    Can anyone tell me what's happening here, please ? Is this a weird
    behaviour or am I doing something wrong ? BTW, this is ASP.NET 2.0.

    Any help would be greatly appreciated.

    Thanks in advance,

    Joao Maia
    João Maia, Jul 2, 2008
    #1
    1. Advertising

  2. João Maia

    João Maia Guest

    Here's some more information regarding this issue:

    It appears that the page I mentioned does a redirect to itself and, on
    the redirection, sends a completely different set of parameters and
    the one named "name" (and defined in VaryByParam) is not included. So
    what I think is happening is this:

    - a.aspx called with name=john and a bunch of other parameters
    - a.aspx does a redirect to itself with some parameters and no "name"
    parameter
    - the result of the redirection is what actually gets cached
    - a.aspx called with name=mary
    - a.aspx does another redirect to itself without the "name" parameter
    - since there is a cached version of the page for when the "name"
    parameter does not exist, this is the one that gets returned and not
    the one for mary

    Is there any workaround to this issue ? As for why a.aspx redirects to
    itself without the same parameters, don't even ask, I can only say
    that it has to be like that, it has to do with a workflow engine that
    I'm using that calls the pages depending on workflow activities. I'm
    not the one actually doing the redirection, the workflow engine is
    doing it by itself.

    Any help at all would be appreciated.

    Thanks in advance,

    Joao Maia

    On 2 Jul, 12:03, João Maia <> wrote:
    > Hello there,
    >
    > I'm using Cache VaryByParam on a page and I'm not getting the
    > behaviour I expected. Here's what happens:
    >
    > - I have page a.aspx declared with Cache VaryByParam="name"
    > - Page a.aspx has a label in which I set the time the page was
    > retireved by using DateTime.Now() on the server side (just to what
    > version of the page I'm getting, and if the cache is working)
    > - My requests to page a.aspx are generated in other pages, and usually
    > have more than one query string parameter, but the parameter "name" is
    > always there. For example,
    >
    > "http://someserver.com/a.aspx?name=john&age=30", or
    > "http://someserver.com/a.aspx?name=john&age=30&city=lisbon" or
    > "http://someserver.com/a.aspx?city=30&name=john"
    >
    > What I was expecting is that, when parameter "name" is "john", a.aspx
    > would be retrieved from the cache regardless of the values of the
    > other parameters. When the parameter "name" would change to "mary"
    > then a new version of a.aspx should be retrieved from the server
    > instead of from cache.
    >
    > What's happening instead is that the page is ALWAYS retrieved from
    > cache (I can say that because of the datetime label I have on the
    > page), regardless of the value of query string parameter "name".
    >
    > Can anyone tell me what's happening here, please ? Is this a weird
    > behaviour or am I doing something wrong ? BTW, this is ASP.NET 2.0.
    >
    > Any help would be greatly appreciated.
    >
    > Thanks in advance,
    >
    > Joao Maia
    João Maia, Jul 2, 2008
    #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. Jeff Nokes

    Cache::Cache Stale Segments

    Jeff Nokes, Sep 30, 2003, in forum: Perl
    Replies:
    0
    Views:
    558
    Jeff Nokes
    Sep 30, 2003
  2. Les Caudle
    Replies:
    2
    Views:
    3,010
    =?Utf-8?B?c3Vuc2hpbmU=?=
    Jun 26, 2004
  3. Dmitry Duginov

    cache (VaryByParam) doesn't work

    Dmitry Duginov, Nov 22, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    1,225
    Steven Cheng[MSFT]
    Nov 29, 2004
  4. z. f.
    Replies:
    0
    Views:
    417
    z. f.
    Feb 10, 2005
  5. z. f.
    Replies:
    5
    Views:
    4,605
    Juan T. Llibre
    Feb 10, 2005
Loading...

Share This Page