Return
|
Stop Browsers from Caching a Page so that Data Updates without Refreshing the Page
|
On occasion you'll have a browser render a cached version of a web page when you want the data shown to always be the most up to date. This can be especially annoying on posted forms where a user may see old data even though the underlying data really was updated.
To keep browsers from caching a page add the following to the page load routine:
|
If Not Page.IsPostBack Then
'---First page load only
System.Web.HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache")
System.Web.HttpContext.Current.Response.Expires = 0
System.Web.HttpContext.Current.Response.Cache.SetNoStore()
System.Web.HttpContext.Current.Response.AddHeader("Pragma", "no-cache")
End If
|
|
|
|
Return
|