AngelEyes on .Net

Tips, tricks and WTFs about Asp .Net, SQL Server and the likes.
posts - 54 , comments - 235 , trackbacks - 6

My Links

News

Tag Cloud

Archives

Image Galleries

3rd party

Official ASP .NET

Useful info

A good explanation on how to use VeryByCustom Caching

Right there: http://www.aprogrammersjournal.com/article.aspx?id=58

 

 

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

</script>


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.

Print | posted on Thursday, February 15, 2007 7:49 AM |

Feedback

Gravatar

# re: A good explanation on how to use VeryByCustom Caching

I started to use VeryByCustom Caching before a short time.
3/26/2009 8:23 PM | sikiş video izle
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: