Geeks With Blogs
AngelEyes on .Net Tips, tricks and WTFs about Asp .Net, SQL Server and the likes.

Right there:



The important part is this:

application level parameters

Application level parameters such as session variables or client side cookies are parameters that are page independent. To cach multiple versions of a page based on application level parameters you can use VarByCustom and the
global.asax file.

In my case the problem I was faced with was using Forms.Authentication in combination with output caching. If user A logged into my site I did not want it to "Welcome User A" to User B.

he first thing we will need to do is set the location of the output cache to "client or "server, this ensures that the page will not be cached by a proxy server. To learn more about caching location please visit:
This Link

Secondly you will need to set up an override function in your global.asax file

<Script language="VB" runat="server">

Public Overrides Function GetVaryByCustomString( _
ByVal context As System.Web.HttpContext, _
ByVal custom As String) As String

Select custom
     Case "username"
               Return Context.User.Identity.Name 
     Case Else
               Return MyBase.GetVaryByCustomString(context, custom)
End Select

End Function


And lastly specify your custom variable:

<%@ OutputCache Duration = "1200" VaryByParam="*" Location="Server" VaryByCustom="username" %>

So now if a user logs in he will receive his own custom cached page, as he browses around the site and hits the same pages, he will receive the pages that were cached for him.

Posted on Thursday, February 15, 2007 7:49 AM | Back to top

Comments on this post: A good explanation on how to use VeryByCustom Caching

# re: A good explanation on how to use VeryByCustom Caching
Requesting Gravatar...
I started to use VeryByCustom Caching before a short time.
Left by sikiş video izle on Mar 26, 2009 8:23 PM

Your comment:
 (will show your gravatar)

Copyright © AngelEyes | Powered by: