Cache for asp.net user control

B

Billy Zhang

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
 
M

Michael Nemtsev [MVP]

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
 
B

Billy Zhang

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?
 
J

Jialiang Ge [MSFT]

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 ([email protected], 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:
(e-mail address removed).

==================================================
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 said:
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 said:
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
 
J

Jialiang Ge [MSFT]

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 ([email protected], 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:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,965
Messages
2,570,148
Members
46,710
Latest member
FredricRen

Latest Threads

Top