devxlogo

Prevent the browser from caching an ASP page

Prevent the browser from caching an ASP page

Most ASP books and articles state that you need to set the Respose.Expires property to 0 or -1 to prevent the end user’s browser from caching an ASP page. However, this is only partially correct, because in order to work correctly for all browsers brands and versions, you also need to add a special Pragma HTTP header, and to disable any caching by a proxy. This is the ASP code you should put on top of your page to achieve the desired behavior:

' WARNING: you should run these statement before sending any HTML to the user.' if in doubt, use Respose.Buffer = True to buffer all html Response.CacheControl = "no-cache"Response.AddHeader "Pragma", "no-cache"Response.Expires = -1

devx-admin

Share the Post: