Prevent ASP page from being cached

If you attempt to use response.redirect after you've already used response.write, you'll receive an error. The following code sample takes care of buffering the output to the browser as well as prevent your page from being cached by IIS. This forces IIS to reprocess the page each time it's called.

If you attempt to use response.redirect after you've already used response.write, you'll receive an error.
The following code sample takes care of buffering the output to the browser as well as prevent your page from being cached by IIS. This forces IIS to reprocess the page each time it's called.


<%
Response.Buffer = True
Response.AddHeader "cache-control", "private"
Response.AddHeader "pragma", "no-cache"
Response.ExpiresAbsolute = #January 1, 1990 00:00:01#
Response.Expires=0
%>


Submission Date:  9/23/2005 3:02:22 PM
Submitted By:  Robbe Morris
My Home Page:  http://www.robbemorris.com

By Robbe Morris   Popularity  (591 Views)
Picture
Biography - Robbe Morris
Robbe has been a Microsoft MVP in C# since 2004. He is also the co-founder of NullSkull.com which provides .NET articles, book reviews, software reviews, and software download and purchase advice.  Robbe also loves to scuba dive and go deep sea fishing in the Florida Keys or off the coast of Daytona Beach. Microsoft MVP