What I did was change all my aspx pages to extend from a common class (BasePage). Then in the OnLoadComplete event in the BasePage, I added all kinds of Response (see below) - but when I access these pages then check my trace.axd for the Request, I don't see anything in the Headers collection or the server variables (ALL_HTTP, ALL_RAW, etc.) that leads me to believe that the page isn't expired in cache. How can I verify that the page isn't being cached but downloaded each time?
"BasePage" code below:
Public Class BasePage
Inherits System.Web.UI.Page
Protected Overrides Sub OnLoadComplete(ByVal e As System.EventArgs)
If Page.IsPostBack Then
Else
Response.AppendHeader("Pragma", "no-cache")
Response.AppendHeader("Cache-Control", "no-store");
Response.Cache.SetNoStore()
Response.Cache.SetExpires(DateTime.Parse(DateTime.Now.ToString()))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Expires = -1
End If
MyBase.OnLoadComplete(e)
End Sub
End Class
Imports Microsoft.VisualBasic
Public Class BasePage
Inherits System.Web.UI.Page
Protected Overrides Sub OnLoadComplete(ByVal e As System.EventArgs)
If Page.IsPostBack Then
Else
'Response.AddHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT")
'Response.AddHeader("Last-Modified", "Sat, 1 Jan 2000 00:00:00 GMT")
Response.AppendHeader("Pragma", "no-cache")
Response.AppendHeader("Cache-Control", "no-store");
Response.Cache.SetNoStore()
Response.Cache.SetExpires(DateTime.Parse(DateTime.Now.ToString()))
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Expires = -1
End If
MyBase.OnLoadComplete(e)
End Sub
End Class