Force browser to refresh page when using ajax with Coldfusion

Posted on 2010-01-09
Medium Priority
Last Modified: 2012-05-08

I am seeing issues with a heavily Ajax reliant application I have written where the users browser is not not automatically refreshing the page content when required and still using the cached version.

I initially though that this was IE only but it would appear that Chrome is having the same issue on the Mac.

Can anyone suggest a way to code around this and force the browser to recognise the new content?
At the moment I am having to instruct the client to ensure that all browsers cache setting are manually adjusted.

Question by:Lmillard
LVL 12

Expert Comment

ID: 26273705
Hi there;

This may be helpful for you:

Best regards.
<script type="text/JavaScript">
function timedRefresh(timeoutPeriod) {
<body onload="JavaScript:timedRefresh(5000);">
<p>5 second refresh.</p>

Open in new window


Author Comment

ID: 26273737
Hi, Thanks for this but it is a server content that is being read from cache rather than being read from the server. i.e a customer record is amended via an update form but if the record is viewed again the change is not viewable on the webpage although it has been applied correctly in the database.

I am attempting to force the server side code to be re-read with each visit to the page. In IE this can be achieved via the Tools --> Internet Settings --> General  tab where there is a 'check for newer version of stored pages' setting but this is not available in all browsers so I am trying to force this to happen with server side Coldfusion code.

LVL 22

Accepted Solution

kadaba earned 2000 total points
ID: 26273869
Well are you using time stamp for every ajax request...

Author Comment

ID: 26274031
Is this a guaranteed method to get around the issue? if so I will add this to the top of each page.
LVL 53

Expert Comment

ID: 26274283

It's worth noting there are "no-cache" headers (ie directives) you can add to each page to indicate the page should not be cached. But the only thing that's ever worked reliably for me in the past is what @kadaba's suggested.  Adding a random string/timestamp makes the browser think it's viewing a new page ie something it hasn't seen before.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question