65.9K
CodeProject is changing. Read more.
Home

Classic ASP - Prevent Cache from being stored

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1 vote)

Oct 30, 2012

CPOL
viewsIcon

27351

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 

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.