468,771 Members | 1,940 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

Cache VaryByParam problems

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
Jul 2 '08 #1
1 1440
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 <jm...@yahoo.comwrote:
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
Jul 2 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by A.M | last post: by
7 posts views Thread by A.M | last post: by
7 posts views Thread by Dmitry Duginov | last post: by
2 posts views Thread by jack | last post: by
3 posts views Thread by ary | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.