Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making sure you're displaying fresh content. 2

Status
Not open for further replies.

MasterRacker

New member
Oct 13, 1999
3,343
US
I know how to use the "refresh" direcive in a meta tag to refresh a page on a time interval. The question is: how do I make a page refresh once to make sure it's not coming from a viewer's local cache? I'd like to refresh once on load or better yet, refresh upon loading when the server content is newer than the cached page.
Jeff
masterracker@hotmail.com

If everything seems to be going well: you don't have enough information.......
 
i think there is a header that you can have on a page to make sure that it doesn't get cached, i'm not sure, but i think it's

<meta http-equiv=&quot;pragma&quot; content=&quot;no-cache&quot;>

or if you dont mind using asp:

<%@ Language=JScript %>
<%
Response.CacheControl = &quot;no-cache&quot;
Response.AddHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
Response.Expires = -1
%>

you can put that at the top of your page.

this probably isnt the best way to do what you want, but it's easy.
 
Actually, it is the best way. Note that luciddream was assuming you're using IIS.

nick bulka

 
that's what the first example was for. the second states that if you want that it is asp, but if you're not using IIS, here's an example that should work with any other webserver, if you have perl asp installed. actually its the same as above, slightly modified...

<%@Language = PerlScript %>
<%
$Response->CacheControl = &quot;no-cache&quot;;
$Response->Expires = -1;
%>
 
Nick,

Which is the best way, the meta tag or the asp code? Would the Jscript code work as in-line jscript? The main page I want to do this on already exists and many folks have links to it so I don't want to have to change the name to &quot;welcome.asp&quot; if I can avoid it.

(I know I could make &quot;welcome.html&quot; jump to &quot;Welcome.asp&quot; but I have other reasons for wanting to avoid that at this time.)
Jeff
masterracker@hotmail.com

If everything seems to be going well: you don't have enough information.......
 
Must have posted simultaneously with lucid's second post. I'll try the meta tag. I am using IIS and prefer to keep my scripting to MS's Jscript and VBScript.
Jeff
masterracker@hotmail.com

If everything seems to be going well: you don't have enough information.......
 
You could just put a random variable in the URL of the calling page - that way the URL will almost always (always if it is some kind of date / time driven variable) be different to anything that is cached and so force loading of current page, instead of viewing local cached copy.
The advantage of this is that it does not matter what platform you are running on- both client and server.

Simon
 
Swilliams: very good, but how can I put a random variable in the URL ?
Please give an example.----G.Hoffmann
 
In your scripting - whatever you are using - create a variable and append this to the URL - ie yourpage.asp?Rand=#variable#

ASP Example:
<HTML>
<body>
<%
Dim sRand
sRand = Left(Now(),Len(Now())-3)
sRand = Right(sRand,2) + Mid(sRand,Len(sRand)-4,2)*60
%>

<form action=&quot;page2.asp?Rand=<%=sRand%>&quot; name=&quot;frmTest&quot; method=&quot;POST&quot;>
<input type=&quot;Submit&quot;>
</form>
</body>
</HTML>

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top