No-Cache and Expiry

  • Thread starter Thread starter Gareth
  • Start date Start date
G

Gareth

Does anyone know how to make an ASP.NET (C#) page expire immediately and not
be cached?
What I want to happen is if the users pressed the BACK button they get a
page has expired and has to be reloaded message.
I've tried just placing the standard HTML meta tags in but that doesn't seem
to work. I've also tried using the Cache objects properties too. That didn't
seem to work either.

Anyone any ideas?

Thanks,
Gareth
 
Place the following code at the top of your aspx page.

<% 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")%>

Tommy,
 
Back
Top