The aspx page chart.aspx returns the requested chart by
dynamically drawing the chart and includes the date
generated and the authenticated username that requested it
within the graphic.
The code of chart.aspx includes the following lines of
code:
Response.Cache.SetCacheability(HttpCacheability.Se rver);
Response.Cache.SetExpires((DateTime.Now.AddSeconds (
chartid * 30 )));
Response.Cache.VaryByParams["*"] = true;
Response.Cache.SetValidUntilExpires(true);
#TEST A#
By loading display.htm as UserA in the browser and
repeatedly hitting refresh you can see that the generated
charts are cached and each chart gets refreshed using it
own assigned expiry time - as you'd expect. If you go to
another users machine (UserB) and do the same you'll
initially see cached charts which were generated for UserA
(and not UserB) - again as you'd expect.
Now add the line:
Response.Cache.SetVaryByCustom("authuser");
and implement the function below within global.aspx
public override string GetVaryByCustomString(HttpContext
context, string arg)
{
if (arg.ToLower() == "authuser" &&
context.User.Identity.IsAuthenticated)
{
return context.User.Identity.Name;
}
}
#TEST B#
Now by loading display.htm and repeating TEST A you will
find that each user has their own individual cached copy
of the chart. Again each chart will have it's own expiry
time. No surprises there.
But if we were to programmatically decide whether the
chart should be cached per user by adding
if(chartid % 2 == 0)
Response.Cache.SetVaryByCustom("authuser");
and then repeating 'TEST A' you'd expect some charts to be
shared between users and some not - what actually happens
is the cache (for all copies of chart.aspx -regardless of
url) are cleared when SetVaryByCustom is switch on and off
between generated charts effectively turning off caching.
I hope this explains the problem. It's not a show stopper
for me but I think it is an issue that should either be
documented or fixed.
Many thanks for taking an interest
Darren Voisey
[my hotmail address is obvious]
-----Original Message-----
Hello,
After studied the problem, I think the problem may not be
related to theexpire time. As Jacob mention, we can only have one cache
policy for asingle cached component. Since all of your charts are in
same web form, Ithink they should use same cache policy. If my
understanding is inccorect,please feel free to correct me.
Luke
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties,
and confers norights.)
.