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

how to force page refresh/reload? 1

Status
Not open for further replies.

theotrain

Programmer
Mar 5, 2003
150
0
0
MX
Im not sure this is even a coldfusion question, but Im building a store in CF and if you use the browsers "back" button, you go back to the previous page EXACTLY as it was- it does not reflect any changes that may have been made to the shopping cart/session variables.

It seems like in order for the pages to display correct information at all times, I would have to force a reload of each page, so the user is never looking at a cached page.

How can I do this?
 
You might try disabling the cache for the page. With dynamically-served pages, sometimes it works, sometimes it doesn't. It's tough to say until you try it in your particular situation.

In the <HEAD> of your page:
Code:
<META HTTP-EQUIV=&quot;Pragma&quot; CONTENT=&quot;no-cache&quot;>  
<META HTTP-EQUIV=&quot;cache-control&quot; CONTENT=&quot;no-cache, no-store, must-revalidate&quot;>
<META HTTP-EQUIV=&quot;Expires&quot; CONTENT=&quot;Mon, 01 Jan 1970 23:59:59 GMT&quot;>

(there are other versions of this using other values for the meta data - most notably
Code:
HTTP-EQUIV=&quot;Expires&quot; CONTENT=&quot;0&quot;
- but the above seems to be the most compatible across current browsers... Netscape 7 gets a bit pissed at the EXPIRES = 0 concept)
-Carl
 
that seems like a perfect solution, to simply not cache the pages. when I tried that code though, it didnt have the desired result. I even tried a more brute force refresh this way:

<cfparam name=&quot;session.fresh&quot; default=&quot;0&quot;>
<cfif session.fresh eq 0>
<cfset session.fresh = 1>
<script>
window.location.reload(true);
</script>
<cfelse>
<cfset session.fresh = 0>
</cfif>

which should cause the page to refresh itself one time, then continue, but this also did not have the same effect as actually hitting the &quot;reload&quot; button in the browser. If I go to barnes and nobles website and add a bunch of crap to my cart, then keep hitting the &quot;back&quot; button, the previous pages correctly report the number of items currently in my cart, they dont begin counting backwards, but thats what my pages do! any more ideas? PLEASE?

 
I'm not sure if it matters much, but on a project that
I did, instead of using META tags, I used CFHEADER
tags. (For all I know, they might be equivalent, but it
seemed to work for me so far, and its probably worth a try.)

Code:
<CFHEADER NAME=&quot;Expires&quot; VALUE=&quot;Mon, 06 Jan 1990 00:00:01 GMT&quot;>
<CFHEADER NAME=&quot;Pragma&quot; VALUE=&quot;no-cache&quot;>
<CFHEADER NAME=&quot;cache-control&quot; VALUE=&quot;no-cache&quot;>

Hope it works,
MG
 
have u tried this??

<META HTTP-EQUIV=&quot;REFRESH&quot; CONTENT=&quot;0&quot;>
 
If you're using IIS, you can also do this:
Under properties for the site,
click the http-headers Tab
click enable content expiration
Click expire content immediately


Also, in your cfadministrator, under caching
make sure the &quot;use trusted cache&quot; checkbox is not checked.

Hope this helps-Neal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top