Automatically refresh SQLDataSource cache after expired

593 views Asked by At

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

There are 1 answers

4
Jeremy Thompson On BEST ANSWER

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