?
Solved

Force browser to refresh page when using ajax with Coldfusion

Posted on 2010-01-09
5
Medium Priority
?
516 Views
Last Modified: 2012-05-08
Hi,

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.

Cheers
Leigh
0
Comment
Question by:Lmillard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Expert Comment

by:jazzIIIlove
ID: 26273705
Hi there;

This may be helpful for you:

Best regards.
<html>
<head>
<script type="text/JavaScript">
function timedRefresh(timeoutPeriod) {
	setTimeout("location.reload(true);",timeoutPeriod);
}
</script>
</head>
<body onload="JavaScript:timedRefresh(5000);">
<p>5 second refresh.</p>
</body>
</html>

Open in new window

0
 

Author Comment

by:Lmillard
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.

Regards
Leigh
0
 
LVL 22

Accepted Solution

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

Author Comment

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

Expert Comment

by:_agx_
ID: 26274283
@kadaba

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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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

800 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