Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Ajax
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Ajax section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #11 (permalink)  
Old January 19th, 2006, 11:17 AM
Authorized User
 
Join Date: Oct 2005
Location: , , .
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

append this.

var lURLToSend = "pageName.php" + "?r=" + new Date().getTime();
the getTime() method will provide an arbitrary, yet not
repeating value (milliseconds since January 1, 1970 00:00:00.000 UTC.)



Nintendo Gamecube & Revolution
http://www.gamecube-revolution.com
Reply With Quote
  #12 (permalink)  
Old January 23rd, 2006, 07:06 PM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 21
Thanks: 0
Thanked 1 Time in 1 Post
Default

That looks like an elegant way to handle it. Thanks.

Reply With Quote
  #13 (permalink)  
Old February 2nd, 2006, 05:49 PM
jmcpeak's Avatar
Wrox Author
Points: 467, Level: 7
Points: 467, Level: 7 Points: 467, Level: 7 Points: 467, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , Texas, USA.
Posts: 87
Thanks: 0
Thanked 17 Times in 16 Posts
Default

IE caches all data retrieved via XmlHttp, just to clarify what the problem is.

A server-side solution would be to set the Cache-Control header for the page, assuming you're using a server-side technology to generate the data. In C# (ASP.NET), use the Response object:

Code:
Response.CacheControl = "no-cache";
With PHP, use the header() function:

Code:
header("Cache-Control: no-cache");
It adds an extra line to your backend code, but it keeps your client-side code a bit cleaner.

------------------------
Jeremy McPeak
Author, Professional Ajax
Reply With Quote
  #14 (permalink)  
Old March 2nd, 2006, 04:55 PM
Registered User
 
Join Date: Feb 2006
Location: , germany, .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same problem...

FireFox works fine if I add the following header but IE not:
header("Cache-Control: no-cache");

then I have tried adding ALSO a query string:
var lURLToSend = "pageName.php" + "?r=" + new Date().getTime();
then IE works fine and FireFox not...

:(

PHP newby
Reply With Quote
  #15 (permalink)  
Old May 4th, 2006, 07:12 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had the same problem particulary when using ajax to perform SQL Queries, checks would stop working after x amount of rapid clicks and my
inline editing needed a shift+refresh in IE in order for it to show the correct values.

Thanks to this thread i now use both the head technique in between </BODY> and </HTML> as well as sending all my http requests with unique url's thanks to Date().Time() and it's working like a charm.

Thanks guys!

Reply With Quote
  #16 (permalink)  
Old February 1st, 2007, 10:26 PM
Registered User
 
Join Date: Feb 2007
Location: , , USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Guys,

Here is the elegant solution you're looking for - found it on Wikipedia, of all places. I just implemented it and it works like a charm.

req.open( "GET", "xmlprovider.aspx" );
req.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
req.send( null );

http://en.wikipedia.org/wiki/Xmlhttp...r_cache_issues

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Recommend an AJAX IDE - JoyiStar AJAX WebShop. kingstar Ajax 4 December 15th, 2006 05:12 AM
AJAX and Browser Caches gregson09 Ajax 1 December 11th, 2006 06:44 AM
new Ajax article: Creating an Ajax Search Widget jminatel Ajax 0 May 11th, 2006 03:50 PM
New Ajax Article: Ajax Submission Throttling jminatel Ajax 0 April 11th, 2006 09:00 PM
Prevent browser from caching? itekcorp ASP.NET 1.0 and 1.1 Basics 1 October 1st, 2003 09:32 AM



All times are GMT -4. The time now is 08:47 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.