Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Page Caching on Server 1

Status
Not open for further replies.

warpped

MIS
Jan 19, 2000
59
US
Is it possible to cache a page on the web server so that all users see the same data from that page? Then after a period of time, the server refreshes the data on the page.

So, the user gets cached data, queried from SQL Server, even after clicking refresh until the server updates the content. Also, all users accessing the page see the same data until the server refresh.

I hope I'm explaining myself weel enough. Thanks in advance.
 
vinnyf: The typical approach to page caching is to use the directive:

<%@ OutputCache Duration="300" VaryByParam="None"%>

I believe 300 seconds is the maxium. If there is a QS variable you can modify this. The above is for a straight forward page with no incoming variables.
 
vinnyf: Here are some additional links to articles talking about asp.net page caching, on both the server and client side. Should be enough info here to help you through this.
 
I'm not an expert here so I'm just going to tell you how I would solve this problem.

I would create an object designed to contain the data I've retreived from the server and has a time stamp (Hmm - extend a DataSet and add a timestamp? Don't know if timestamps are built into datasets). Store this data in Application scope and everytime someone gets the page render it from the store.

To control the update rate, check the timestamp every time you retreive it and compare it against a set duration. If one of your requests sees that the duration is up - lock the application object (making all other threads wait till your new read operation is complete) and call update on the DataSet.

This way you don't have to go messing arround with your server settings and potentially messing up the caching of other pages on your site.

Criticism on a postcard please ;)


Yet another unchecked rambling brought to you by:
Oddball
 
Criticism on a postcard please ;)
It's overly complicated! [smile]

Simply use the method Isadore suggested or insert your data object into the cache by using Cache.Insert and specifying the relevant time. The page (and any other page) can then simply show the data by retrieving it from the Cache.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Ok - I'm showing my relative lack of experiance again. Never used the Cache object - I'll reasearch that when I get a sec :)

Anyone give me some examples of when to use the Cache over the session and application objects and how it's scope compares?

New stuff interestes me ;)


Yet another unchecked rambling brought to you by:
Oddball
 
Well, the most important difference is that Session is limited to each user whereas the Cache is available to all users.

Here's a article that may interest you:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Thanks to you all for such a quick response. Isadore's advice is exactly what I needed. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top