Cache for asp.net user control

Discussion in 'ASP .Net' started by Billy Zhang, Jun 13, 2008.

  1. Billy Zhang

    Billy Zhang Guest

    Here is a user control on the page, how do I cache it by user?
    Currently I think we could put a server control for example ID:textusername
    in the asp.net page whose value is username, so we can utilize Output cache
    with varybycontrol to control the cache.

    Queation:
    If this is right direction, does this control ID:textusername need to be in
    the user control or just in the asp.net page?

    How do I check if it has been cached successfully?

    If there are 2000 users, how do I check the memory the cache used?

    Thanks,
    -Billy
     
    Billy Zhang, Jun 13, 2008
    #1
    1. Advertising

  2. Hello Billy,

    emm, not quite understand what do u want to get.
    Cache the user name or the value of the control?!
    To have the user-specific cache your can use the Session, or put the value
    to the Cache class with the user name key and hashed by username (to make
    it a bit secure in case of accessing this value from other user)

    ---
    WBR,
    Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

    "The greatest danger for most of us is not that our aim is too high and we
    miss it, but that it is too low and we reach it" (c) Michelangelo


    BZ> Here is a user control on the page, how do I cache it by user?
    BZ> Currently I think we could put a server control for example
    BZ> ID:textusername in the asp.net page whose value is username, so we
    BZ> can utilize Output cache with varybycontrol to control the cache.
    BZ>
    BZ> Queation:
    BZ> If this is right direction, does this control ID:textusername need
    BZ> to be in
    BZ> the user control or just in the asp.net page?
    BZ> How do I check if it has been cached successfully?
    BZ>
    BZ> If there are 2000 users, how do I check the memory the cache used?
    BZ>
    BZ> Thanks,
    BZ> -Billy
     
    Michael Nemtsev [MVP], Jun 13, 2008
    #2
    1. Advertising

  3. Billy Zhang

    Billy Zhang Guest

    I want to cache a usercontrol by using Output cache.
    There are two ways: VaryByControl and VaryByCustom.

    Since I want to cache this usercontrol by different user, could i use
    VaryByControl to control this?

    If there are 2000 users, how do I check the memory the cache used?

    "Michael Nemtsev [MVP]" wrote:

    > Hello Billy,
    >
    > emm, not quite understand what do u want to get.
    > Cache the user name or the value of the control?!
    > To have the user-specific cache your can use the Session, or put the value
    > to the Cache class with the user name key and hashed by username (to make
    > it a bit secure in case of accessing this value from other user)
    >
    > ---
    > WBR,
    > Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour
    >
    > "The greatest danger for most of us is not that our aim is too high and we
    > miss it, but that it is too low and we reach it" (c) Michelangelo
    >
    >
    > BZ> Here is a user control on the page, how do I cache it by user?
    > BZ> Currently I think we could put a server control for example
    > BZ> ID:textusername in the asp.net page whose value is username, so we
    > BZ> can utilize Output cache with varybycontrol to control the cache.
    > BZ>
    > BZ> Queation:
    > BZ> If this is right direction, does this control ID:textusername need
    > BZ> to be in
    > BZ> the user control or just in the asp.net page?
    > BZ> How do I check if it has been cached successfully?
    > BZ>
    > BZ> If there are 2000 users, how do I check the memory the cache used?
    > BZ>
    > BZ> Thanks,
    > BZ> -Billy
    >
    >
    >
     
    Billy Zhang, Jun 13, 2008
    #3
  4. Hello

    To cache a user control / a page by user name, as you said, we can either
    use VaryByControl (a trick) or VaryByCustom, but I believe VaryByCusom is a
    more direct way to accomplish the task. There is a blog article may exactly
    meets the need:
    http://aspadvice.com/blogs/ssmith/archive/2007/10/29/VaryByCustom-Caching-By-User.aspx
    Please try it in your user control, and for any other questions, let me
    know!

    In order to monitor the cache usage in asp.net, Steve Smith has written a
    cool application that helps you monitor and manage your cache values in
    ASP.NET. Read all about it here:
    http://aspadvice.com/blogs/ssmith/archive/2005/12/03/Cache_Manager_Almost_Ready.aspx
    There are other open source projects for the same purpose:
    http://aspalliance.com/CacheManager/Default.aspx
    http://www.codeproject.com/KB/web-cache/cachemanagementinaspnet.aspx

    Regards,
    Jialiang Ge (, remove ¡®online.¡¯)
    Microsoft Online Community Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notifications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.


    "Billy Zhang" <> wrote in message
    news:...
    >I want to cache a usercontrol by using Output cache.
    > There are two ways: VaryByControl and VaryByCustom.
    >
    > Since I want to cache this usercontrol by different user, could i use
    > VaryByControl to control this?
    >
    > If there are 2000 users, how do I check the memory the cache used?
    >
    > "Michael Nemtsev [MVP]" wrote:
    >
    >> Hello Billy,
    >>
    >> emm, not quite understand what do u want to get.
    >> Cache the user name or the value of the control?!
    >> To have the user-specific cache your can use the Session, or put the
    >> value
    >> to the Cache class with the user name key and hashed by username (to make
    >> it a bit secure in case of accessing this value from other user)
    >>
    >> ---
    >> WBR,
    >> Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour
    >>
    >> "The greatest danger for most of us is not that our aim is too high and
    >> we
    >> miss it, but that it is too low and we reach it" (c) Michelangelo
    >>
    >>
    >> BZ> Here is a user control on the page, how do I cache it by user?
    >> BZ> Currently I think we could put a server control for example
    >> BZ> ID:textusername in the asp.net page whose value is username, so we
    >> BZ> can utilize Output cache with varybycontrol to control the cache.
    >> BZ>
    >> BZ> Queation:
    >> BZ> If this is right direction, does this control ID:textusername need
    >> BZ> to be in
    >> BZ> the user control or just in the asp.net page?
    >> BZ> How do I check if it has been cached successfully?
    >> BZ>
    >> BZ> If there are 2000 users, how do I check the memory the cache used?
    >> BZ>
    >> BZ> Thanks,
    >> BZ> -Billy
    >>
    >>
    >>
     
    Jialiang Ge [MSFT], Jun 13, 2008
    #4
  5. Hello Billy,

    I am writing to check the status of the issue on your side. Would you mind
    letting me know the result of the suggestions? If you need further
    assistance, feel free to let me know. I will be more than happy to be of
    assistance.

    Have a great day!

    Regards,
    Jialiang Ge (, remove 'online.')
    Microsoft Online Community Support

    =================================================
    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    This posting is provided "AS IS" with no warranties, and confers no rights.
    =================================================
     
    Jialiang Ge [MSFT], Jun 18, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?b25l?=
    Replies:
    1
    Views:
    5,351
    Karl Seguin [MVP]
    Mar 8, 2006
  2. Mad Scientist Jr
    Replies:
    0
    Views:
    682
    Mad Scientist Jr
    Mar 22, 2006
  3. Sergey via DotNetMonster.com

    ASP.NET Cache vs Window System Cache

    Sergey via DotNetMonster.com, Nov 15, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    505
    Sergey via DotNetMonster.com
    Nov 15, 2006
  4. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    585
    Jonathan Wood
    Feb 2, 2010
  5. Yaron Cohen
    Replies:
    0
    Views:
    350
    Yaron Cohen
    Nov 19, 2003
Loading...

Share This Page