[Mono-list] Page Caching, VaryByCustom, VaryByParam

Marc DM m at phronein.com
Tue Aug 30 21:51:40 EDT 2005


Is the ASP.NET Page Caching mechanism complete in Mono 1.1.7

Is there something I need to know about it?

I have the following code in an ASP.NET page :

<%@ OutputCache Duration="600" VaryByParam="pg;lang" 
VaryByCustom="signedin" %>

And then in global.asax.cs (from which global.asax inherits) :

    public class Global : System.Web.HttpApplication
    {
        public override string GetVaryByCustomString(HttpContext 
context, string s)
        {
             if (mynamespace.utils.ContextAuthenticated(context))
                  return s;
             else
                  return "guest";
        }
    }

But it doesn't give me two different versions of the page at all.

Also it doesn't seem to check the cookies collection for the parameter 
to vary by when using VaryByParam. Or am I mistaken to assume that a 
cookie named lang would equate to a param named lang.

I issue a cookie named lang on first visit, and if you want to use a 
different language, you click a link to the current url with lang=de as 
an additional querystring parameter. (assuming you selected de). Loading 
the page with this Querystring param will flip the language, and issue a 
new cookie in the page response.

Thinking about it now, it sounds like if the cookies collection is used, 
then when the link is clicked to switch language, then 2 values for lang 
would be sent. In that case, the first page returned in the new language 
would also be a different cached version than the one we want.

Anywho, VaryByCustom is not working, and VaryByParam is givin me some 
trouble.

Regards,

Marc DM



More information about the Mono-list mailing list