<%@ OutputCache %> is a page level directive. It will cache the contents of X page for a specificed amount of time. This is typically done to reduce the number of calls to a database or on a page that does not change or changes very slowly (a company's About Us page would be a good example of a page that changes very slowly or not at all).
Since you are using a user control, I might do something like this in the user control:
csharp Code:
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack) LoadMenu();
}
private void LoadMenu()
{
if(Cache["Menu"] == null) LoadData();
Menu.Data = Cache["Menu"];
}
private void LoadData()
{
//Database Operation
Cache.Insert("Menu", <your data>, null, DateTime.Now.AddDays(1), TimeSpan.Zero);
}
The over all flow is straightforward so I am not going to explain it. The "magic" happens here: Cache.Insert("Menu", <your data>, null, DateTime.Now.AddDays(1), TimeSpan.Zero); This inserts your Menu data into the cache for one day at which time it will expire and another database call will be made. You do not need to use the global.asax at all.
Now, there is a trade off. You are reducing calls to your Database server but you are putting extra load on the Webserver. Inserting stuff into Cache consumes server memory so it is not wise to insert LARGE amounts of data into the cache. In most normal uses you wont notice an issue or with performance on the server but be aware that this *could* impact server preformance.
hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library:
Wrox Books 24 x 7
Did someone here help you? Click

on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================