Thursday, February 14, 2008

Cache in ASP Classic

Expire Cache and Cookies in ASP Classic


Here are the the commands to place at the top of your ASP scripts to ensure that the page is not cached:

<% Response.Expires = 60 Response.Expiresabsolute = Now() - 1 Response.AddHeader "pragma","no-cache" Response.AddHeader "cache-control","private" Response.CacheControl = "no-cache" %>

Response.Expires = 60
is said to expire at 60 seconds, not 0.

Response.Expiresabsolute=Now()-2
says "expire this page 48 hours ago", allowing for time differences, rather than specify a static date.

Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"