Yeah, anything you cache will cache the stuff inside it. So you're better
off leaving the main ASPX uncached.
---aspx (not cached)
-- some queries
-- multimedia control (cached)
-- some queries
-- multimedia control (cached)
-- some queries
-- listrecords control (not cached)
-- some queries
-- multimedia control (cached)

Signature
After looking at your code again, I realize you don't have to use user
controls, since you're doing server.execute. Which if it works for you, is
probably ok (although user controls may perform better under load).
If you're just concerned about performance, you could change multimedia.aspx
to cache the database results, & leave the HTML generation alone. So in
multimedia.aspx whenever you called the database you could first see if the
dataset was in the cache. If it was't, you'd call the database, get back the
dataset, store it in the cache w/ a key associated with the dataset (e.g.
the objectid), and then use the dataset to draw html, whatever. Kinda like
this:
<%
string strObjectID = Session("ObjectID")
DataSet dsObject = Cache.Get("firstdataset"+strObjectID)
if (dsObject==null) {
// not in cache
// query the database, get back ds & store back in cache
Cache.Insert("firstdataset"+strObjectID, dsObject);
}
// use ds to generate some html, whatever
if (dsObject.RecordCount==1) {
DataSet dsTmp = Cache.Get("seconddataset"+strObjectID)
if (dsTmp==null) {
// not in cache
// query the database, get back ds & store back in cache
Cache.Insert("seconddataset"+strObjectID, dsTmp);
// draw some html
}
else {
DataSet dsTmp = Cache.Get("thirddataset"+strObjectID)
if (dsTmp==null) {
// not in cache
// query the database, get back ds & store back in cache
Cache.Insert("thirddataset"+strObjectID, dsTmp);
// draw some html
}
%>
That would be easier. If you really want to cache the HTML also, you would
need to store the HTML into a big string, & cache that string. Like
<%
string strObjectID = Session("ObjectID")
string strHTML = Cache.Get("html" + strObjectID)
if (strHTML==null) {
// not cached, need to build the HTML
strHTML = ""
strHTML += "<b>some html</b>"
// call the database
foreach(datarowview drv in DataSet.Tables[0].DefaultView) {
strHTML += "some more html" + drv["somefield"]
}
// cache html
Cache.Insert("html" + strObjectID, strHTML)
}
// output html
Response.Write(strHTML)
%>
But I don't think it's worth it...I'd suggest caching the database results
first, see how that works out.
FYI, using outputcache works easily when you have values in the querystring
you can use to distinguish between versions (e.g.
"multimedia.aspx?ObjectID=6561526"). Or if you're using user controls, you
can stick outputcache inside them & have them differentiate on querystring,
browser type, ID (i.e. the ID of the user control). There is also
VaryByCustom where you can do some custom coding for caching, but it may not
work out in your situation.
Good luck, lmk how it works out or if you have further questions. The
ASP.NET QuickStart has some good, easy caching examples. Or google. ;)
--
Ben Strackany
www.developmentnow.com
<a href="http://www.developmentnow.com">dn</a>