0

I have added SQLDataSource control on page with EnableCaching and Cache Duration is 3 hours(10800 Seconds).

I am Showing data from SQLDataSource On Page Load event. I just want to know that, After 3 hours the SQLDataSource refresh automatically or do we need to open page in browser after every 3 hours?

1 Answer 1

1

It cached for 3 hours, if you hit the page again after 3 hours you will get latest. However, its not an AJAX mechanism, if you're expecting to see updated results without hitting the page_load event again then you'll need to add the asynchronous postback stuff yourself.

The SqlDataSource control supports data caching. While data is cached, the Select method retrieves data from the cache rather than from the underlying database. When the cache expires, the Select method retrieves data from the underlying database, and then caches the data again.

Ref: https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.enablecaching(v=vs.110).aspx

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks Jeremy for quick reply. Ok.and we have 10 machines where we open our page. then do we need to we need to open page after 3 hours on every machine for latest cache? OR single Cache is shared by all instances of SQLDataSource objects on different machines?
This might be easier in a Chat room, I am assuming you have 10 client* PCs hitting a single server that hosts the ASP.Net app. The SQLDataSource is stored on the server not on the client PCs so when the single cache is updated then any machine that refreshes (after the cache duration) will see the latest. The best way to understand this is set the cache to a few minutes, update the database and refresh at different times on different PCs to see how it works first-hand * even Stackoverflow runs on less than 10 servers
That's what I want..Really appreciate you..Big thanks.
Cool, if you ever did want to store stuff on client PCs you need to use Javascript (and maybe SignalR to control subscription/Publication events) - when its stored on the client-side thats when each user has their own copy of the data. When its Server-Side there is typically only one instance shared amoung clients (unless you have a server farm, which in that case you would want to use an Out-Of-Process Session State server). For now though, you'll be right with one server and one SQLDataSource caching everything for everyone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.