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

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist