If the data is only used on a single page, you could use page caching
(and it will definitely be better than no caching).
But if you are using the same "semi-static" data on multiple pages,
consider using the application-wide Cache. The same objects are
available from every page (as Page.Cache).
You can retrieve the data once from the database, add it to the cache
and then on subsequent pages, just retrieve the data from the cache.
Quick code (not guaranteed to compile as-is, read the documentation):
Page_Load(){
// try to retrieve data from cache
DataSet myData = Cache["MyDataKey"] as DataSet;
if (myData == null){
// data was not in cache, retrieve from database
myData = LoadDataSetFromDatabase();
this.Cache.Insert("MyDataKey", myData);
}
// use myData
}
The different overloads of Cache.Insert() allow you to specify different
rules for how long the data should stay in the cache.
Joshua Flanagan
http://flimflan.com/blog
Aaron wrote:
Some of my db-driven web pages rarely change. They pull the exact same data
every time (the table is almost read-only). Should I consider using page
caching? or do i just need to turn on caching in IIS 6? I'm new to this.
could someone point me to the right direction?
Thanks,
Aaron