Control Caching Problem - HELP!?

  • Thread starter Thread starter Stewart
  • Start date Start date
S

Stewart

Hi all, hoping one of you may be able to throw up an idea on the
following. I have an asp.net page with a drop-down and a user control
inside. The user control should be cached in one way or another as it
takes a lot of database work to produce.

-----------------------------------------
| |
| DROP DOWN V |
| |
| ------------------ |
| | | |
| | USER CONTROL | |
| | | |
| ------------------ |
| |
| |
| |
-----------------------------------------

Now the problem I am having is that the contents of the drop down
changes from time to time. This prevents us from caching the whole
page for any significant amount of time. The data accessed by the
user control is different depending on the setting of the drop down.
My question is how do I cache the user control output (with a
different version for each drop-down value)?

I've tried:
1) Using VaryByParam, but the default page has no param and hence if
the default selected item in the drop down changes, the user control's
cached output does not.
2) Tried VaryByControl. For this to work the control in question (ie
the dropdown) actually needs to be part of the user control. If we
made it so then we could not update the contents of the dropdown (as
it is cached).

Ideas?

Thanks,

Stewart
 
I don't see why you should cache the User Control. Just cache the data that
takes so long to retrieve from the database, and re-load it into the User
Control with each PostBack. If you brought a gallon of ice cream home in
your car, you wouldn't put the car in the freezer, would you?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Back
Top