Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / VBScript

Classic ASP - Prevent Cache from being stored

5.00/5 (1 vote)
30 Oct 2012CPOL 27.4K  
Classic ASP - Prevent Cache from being stored

Introduction

You will find below the exact code you need in order to prevent cache from being stored. I am posting this in order to help everyone that would ever have the need doing it. I spent myself some hours this last saturday trying to do this trick. I saw many combinations from the same code everywhere in several forums but this is the only one that worked for me, as referenced below 

After filling a form, then going back to the previous page and then forward back again, the form is empty as expected. Nothing is stored in the browser's cache  

Using the code 

All you have to do is place it at the top of your ASP file 

VBScript
Response.buffer=true
Response.Expires = -1
Response.ExpiresAbsolute = Now() -1 
Response.AddHeader "pragma", "no-store"
Response.AddHeader "cache-control","no-store, no-cache, must-revalidate"

Hope it helps.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)