Cache User Control in Web Part

R

Ryan

Hello everyone,

What is the best way to cache a 2.0 web part?

I tried putting output cache on the user control in the part, but the
output cache cannot be wrapped by a generic web part . . . any ideas?

I'm new to caching to begin with and I am at a loss. Because of the
control, data caching wouldn't really be a good option. Maybe if I get
the rendered html code from the control, put that in cache, then
render
that in a literal control . . . that seems a little silly (if it would
even work).

Thanks for any advice,
Ryan
 
A

Alvin Bruney [MVP]

As a general rule, you don't cache the web part, you cache the data in the
web part.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
 
R

Ryan

Thanks Alvin! Maybe I am confused on the point of output cache . . . I
was thinking it would be simpler and quicker if the entire control was
cached. I thought that is what output cache is for. Are you saying
that output cache should not be used, or can I not do that with a web
part, so find a way around it by caching the data?

Thanks!
Ryan
 
A

Alvin Bruney [MVP]

I think i miss read you a bit. output cache will allow this if you use the
varyby* attributes. You don't need to *wrap anything. Here is a good starter
link to understand the process:
http://authors.aspalliance.com/aspxtreme/webapps/cachingmultipleversionsofusercontroloutput.aspx

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
 
C

Charisse

Hi Alvin,

I have tried putting a VaryByParam="param_name" in the OutputCache tag of the Web Part user control. But I am still getting the error:

OutputCached controls cannot be wrapped by a GenericWebPart.
Parameter name: control
 
A

Alvin Bruney [MVP]

You can't use an output cached user control as a web part, that
functionality is not supported.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top