Question

Is there a command in classic ASP I can use to tell the browser not to pull the page from it's cache, or, to not cache, or clear the cache of my page?

Was it helpful?

Solution

You can use HTML meta tags:

<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="Fri, 01 Jan 1999 1:00:00 GMT" />
<meta http-equiv="Last-Modified" content="0" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />

Or you can use ASP response headers:

<% 
   Response.CacheControl = "no-cache"
   Response.AddHeader "Pragma", "no-cache"
   Response.Expires = -1
%>

OTHER TIPS

Not asp related, this is a HTTP question. You do it by modifying some aspect of http caching like Cache-Control, etag, Expires etc. Read RFC2616 especially Caching in HTTP and set the appropriate header.

Ignore everybody telling you to use <meta> elements or Pragma. They are very unreliable. You need to set the appropriate HTTP headers. A good tutorial on how to decide which HTTP headers are appropriate for you is available here. Cache-Control: no-cache is probably all you need, but read the tutorial as there are many project-specific reasons why you might want something different.

If you put

Response.Expires = -1

in you classic ASP-page it will instruct the browser not to cache the contents. If the user clicks "back" or navigating to the page in another way, the browser will refresh the page from the server.

Can be done by making sure that you have correct values set for Reponse.cachecontrol, response.expires etc according to your need. This link may be helpful in understanding what they mean. http://aspjavascript.com/lesson07.asp

Because of the way that different browsers handle caching both the Expires and the no-cache commands need to be used. Here is an article showing the correct way to do this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top