470,810 Members | 863 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,810 developers. It's quick & easy.

Caching problem with HTTPRequest???

I've created a page that uses HTTPRequest to include some
XML data and allow the user to update that data. The
problem is that the new data doesn't show up, even though
the XML file is changed.

I can call the XML file up in a separate browser window,
where I get the old data, refresh to get the new data, then
when I refresh the first browser, the new data appears on
the page.

I'm thinking this might be some sort of server caching
issue. Has anyone else run into this? Does anyone have a
solution?
Oct 28 '05 #1
3 1409
Hi,
This is the way to solve it. Aappended a random value to the URL.

var rand = Math.random();
lURLToSend = "pageName.php" + "?" "r=" + rand;

or you can use "POST" method to submit xmlhttp request.

Sincerely,

Tien-Chih Wang

------
Meta Job Search Engine
http://www.onsofts.com/deepJobSearch.jsp

Oct 28 '05 #2
Tien-Chih Wang wrote:
This is the way to solve it.
This is one way to solve it, certainly not the best one.
Aappended a random value to the URL.

var rand = Math.random();
lURLToSend = "pageName.php" + "?" "r=" + rand; ^
Since statistical probability says that a given random value
will reoccur in at least one iteration, this will only prevent
fetching the same URL in some, perhaps many, but not all cases.
The above code also contains a syntax error; because of that it
should read

var lURLToSend = "pageName.php?r=" + Math.random();

Because of the random number issue, it should read

var lURLToSend = "pageName.php" + "?r=" + new Date().getTime();

where the getTime() method will provide an arbitrary, yet not
repeating value (milliseconds since January 1, 1970 00:00:00.000 UTC.)

However, the best approach is a proper caching technique:

<http://www.mnot.net/cache_docs/>
or you can use "POST" method to submit xmlhttp request.
.... which requires one of the more recent user agents.
------
Meta Job Search Engine
http://www.onsofts.com/deepJobSearch.jsp


Advertisements, if any, should be included in a signature properly
delimited with a line containing only "-- <CR><LF>" (without the double
quotes). They may otherwise become subject to official complaints
when posted repeatedly.
PointedEars
Oct 28 '05 #3
Tien-Chih Wang wrote:
This is the way to solve it.
This is one way to solve it, certainly not the best one.
Aappended a random value to the URL.

var rand = Math.random();
lURLToSend = "pageName.php" + "?" "r=" + rand; ^
Since statistical probability says that a given random value
will reoccur in at least one iteration, this will only prevent
fetching the same URL in some, perhaps many, but not all cases.
The above code also contains a syntax error; because of that it
should read

var lURLToSend = "pageName.php?r=" + Math.random();

Because of the random number issue, it should read

var lURLToSend = "pageName.php?r=" + new Date().getTime();

where the getTime() method will provide an arbitrary, yet not
repeating value (milliseconds since January 1, 1970 00:00:00.000 UTC.)

However, the best approach is a proper caching technique:

<http://www.mnot.net/cache_docs/>
or you can use "POST" method to submit xmlhttp request.
.... which requires one of the more recent user agents.
------
Meta Job Search Engine
http://www.onsofts.com/deepJobSearch.jsp


Advertisements, if any, should be included in a signature properly
delimited with a line containing only "-- <CR><LF>" (without the double
quotes). They may otherwise become subject to official complaints
when posted repeatedly.
PointedEars
Oct 29 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dominic Myers | last post: by
2 posts views Thread by jw56578 | last post: by
1 post views Thread by Leonid | last post: by
2 posts views Thread by George1776 | last post: by
2 posts views Thread by adwooley2 | last post: by
2 posts views Thread by shawnwperkins | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.