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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force page reload 3

Status
Not open for further replies.

OldWilly

Programmer
Mar 1, 2002
66
0
0
I'm using this script to load a page into a frame.
<SCRIPT language=&quot;JavaScript&quot;>
top.main.location=&quot;galleryresults3.cfm?#urltoken#&quot;;
</script>

It works good, but lots of times it loads an old view of
the page. Is there something I can add to it to force the
page to re-load?
 
This is just a guess but I know Internet Explorer uses cached pages by default. There is a tag I put at the bottom of all my pages to try and flush the cache and force it to go back to the server everytime. This seems to work for most page elements although I know Explorer will cache style sheets and images no matter what you tell it.

The code is:

</body>
<HEAD><META HTTP-EQUIV=&quot;PRAGMA&quot; CONTENT=&quot;NO-CACHE&quot;></head>
</html>

There is a knowledge base article on the MSDN website that talks about this problem. I don't remember it's number. If you search for &quot;Pragma&quot; you can probably find it. I do remember that the tag has to be at the bottom of the page because Explorer flushes the moment it sees the tag. If you load more page content after the tag it starts caching the bottom part of your page again.
 
Another, non-programmable way, is to set your browser to check the page each time it is loaded, if there is a new version available or not to download.

However, modifying the header (like gelgaard says) is preferrable, as it doesn't depend on the user to have the correct settings. Take Care,
Mike
 
One trick I've seen is to generate a random querystring variable and attach it to the link:

Code:
top.main.location=&quot;galleryresults3.cfm?#urltoken#&x=#Hash(Now())#&quot;;

This makes browser(s) think that the link is to a new page each time, since the querystring is different each time.

You could also generate a random string using CF's random functions, use the CREATEUUID() function, etc. I like the Hash() function, but it's by no means the only function that can accomplish this. If you were to make a clickable link and continuously click it you would notice that the hash() function's output doesn't change if you click it twice within the same second. I know that's anal retentive, but I just wanted to let you know! If you are that worried about it, using CREATEUUID() would be better.

-Tek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top