473,788 Members | 2,898 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX hits being cached??

hello,

im working on my first production AJAX project, and im noticing
something weird.

when my clientside events fire (user clicks on various product rows), i
make an xmlhttp call. in this call i hit a URL and pass it the clicked
productID, such as: "/ajax/productDetail.a spx?pid=666666" . this page
produces XML direct from the database and i render it onscreen. cool.

but what ive noticed is, if this data changes in the db, the AJAX
clientside requests dont get the latest data . but, if i hit the
"/ajax/productDetail.a spx?pid=666666" url directly in a web browser
(where i can see the fresh data), and then go *back* to the clientside
app & try again, it gets the latest data!

so on the surface it looks like the ajax calls to the URL are somehow
cached. can anyone speak to this possibility?

i am running IE 6, win, IIS 5.

my code:
var xmlhttp = false;

//win/IE
try {
xmlhttp = new ActiveXObject(" Msxml2.XMLHTTP" );
} catch (e) {
try {
xmlhttp = new ActiveXObject(" Microsoft.XMLHT TP");
} catch (e2) {
xmlhttp = false;
}
}

//make the call
xmlhttp.open("G ET", url, false); //setting async to false due to
previous lag

xmlhttp.onready statechange = function()
{
if (xmlhttp.readyS tate == 4) //ready
{
if (xmlhttp.status == 200) //success
{
var xml = xmlhttp.respons eXML;

if (xml.documentEl ement){
// [does rendering stuff]
}

} else {
alert('There was a problem retrieving the data:\n' +
xmlhttp.statusT ext);
}
}
xmlhttp.send(nu ll)
}
.....this code successfully produces the xml object that i then render
into htlml DIV tags. but the data its getting is stale.

thanks!
matt

May 24 '06 #1
5 1502
ma************* @shell.com wrote:
im working on my first production AJAX project,
I doubt that you will take it well, but I suspect that you are not yet
qualified for that undertaking.
and im noticing something weird.
And archive search would reveal that it is neither unusual nor uncommon.

<snip> so on the surface it looks like the ajax calls to the
URL are somehow cached. can anyone speak to this possibility?
Any resource accessed with HTTP may be cached. Factors influencing
caching include browser settings, HTTP headers sent with the request and
the type of the request. GET requests are particularly prone to being
cached.

Writing an AJAX project without a familiarity with RFC 2616 (HTTP 1.1)
is distinctly optemistic.

<snip> var xmlhttp = false;

//win/IE
try {
xmlhttp = new ActiveXObject(" Msxml2.XMLHTTP" );
} catch (e) {
try {
xmlhttp = new ActiveXObject(" Microsoft.XMLHT TP");
} catch (e2) {
xmlhttp = false;
}
}
What is the point of having the - catch - clause set the xmlhttp
variable to false if you then go on to call a method of xmlhttp without
verifying that it is not false at that point?

Is this for an Intranet? otherwise assuming that ActiveX will be
available on the client is also optimistic.
//make the call
xmlhttp.open("G ET", url, false); //setting async to false due
to previous lag

<snip>

Making synchronous XML HTTP requests is a mistake. You should solve the
issue that makes you think it is necessary now because it will become a
problem very soon, and when it does you may have gone too far to make
going back to this point and solving the issue properly an appealing
prospect.

Richard.
May 24 '06 #2

ma************* @shell.com wrote:
hello,

im working on my first production AJAX project From a brief glance at the code you posted it looks like you are taking

care of the cross browser issues yourself. Have you thought about using
code like Yahoo! UI connection library or the code at ajaxtoolbox.com ?
These might reduce the number of things you have to worry about.

Disclaimer. Perhaps you are doing something special that needs custom
code. (Have to be careful with what you say around here.)

Peter

May 25 '06 #3
ma************* @shell.com wrote:
(...) but what ive noticed is, if this data changes in the db, the
AJAX clientside requests dont get the latest data . but, if i hit the
"/ajax/productDetail.a spx?pid=666666" url directly in a web browser
(where i can see the fresh data), and then go *back* to the
clientside app & try again, it gets the latest data! (...)


Iirc, IE caches ajax GET requests by default. Maybe setting some header
on the response (within the server) can solve it. A workaround is to
use POST requests, which may or may not be deemed acceptable (it surely
isn't pretty, but has no side effects that I know of. I don't know
everything, though).
--
am

laurus : rhodophyta : brezoneg : smalltalk : stargate
May 25 '06 #4
> make an xmlhttp call. in this call i hit a URL and pass it the clicked
productID, such as: "/ajax/productDetail.a spx?pid=666666" . this page
produces XML direct from the database and i render it onscreen. cool.


Try to add a timestamp:
var tm=new Date();
... "/ajax/productDetail.a spx?pid=666666& time="+tm.getTi me();

and/or do something with response header as António suggest

include xmlhttprequest. js from Andrew Gregory:
http://www.scss.com.au/family/andrew...mlhttprequest/

and use XMLHttpRequest( ) for all browsers

I also recommend JSON for better portability between browsers

arnulf @ http://rlb.no/my/

May 25 '06 #5
> I doubt that you will take it well, but I suspect that you are not yet
qualified for that undertaking.
hi richard, mind if i call you DICK?

i know it may shock your uber-brain, but this stuff aint rocket
science. the balance of world economies or life & limb are neither at
stake. its a web app. big whoop.

i was writing clientside code w/ the MS xmlhttp object in 2002,
probably long before you hopped on the "AJAX" bandwagon. we just didnt
call it as such back then, and there was no uniform browser support --
only intranets on IE. which, happily, is what i am working on again
now, 4 years later.

however, as my particular focus of coding generally shifts from project
to project, depending on my clients, i dont remember all the
particulars of lesser-used areas. do you? great! i can admire that.
wish i had your memory.

What is the point of having the - catch - clause set the xmlhttp
variable to false if you then go on to call a method of xmlhttp without
verifying that it is not false at that point?
again, another shock to your brain -- i snipped my code samples for
brevity. you know, the whole "Save the Bandwidth!" thing?

Is this for an Intranet? otherwise assuming that ActiveX will be
available on the client is also optimistic.
yes, i am aware of my clients environment, thanks.

Making synchronous XML HTTP requests is a mistake.


as you have no idea what the context of this code is, ill be the judge
of that. but thanks for the concern.
arrogant & snide posts aside, the problem here was that of caching,
from the xml-producing page. two simple response headers (recommended
from another forum, where, amazingly, people are friendly instead of
righteous) put an end to that.
but thanks for your 'tude, dude. you may have the last word -- insult
me further, mock my l0053r skillz, whatever it is that makes you feel
good about yourself. me, im a professional, and i like to spend as
little time not-coding & not-billing as possible. as such, this thread
is no longer on my watched items.

flame on!!
matt

May 25 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3688
by: GTi | last post by:
I have a bizare Ajax POST problem. I use Ajax POST to send data to the server. The server get the POST and answer back. BUT if I POST the data once again I recieve the same answer that the first post give me, even if the answer is different. I have used HTTP Analyser Std V2.1.1.15 and I see that the answer is different. But the Ajax .responseText is the same as the first POST. It looks like it use the cached respons. In the RFC the...
1
1942
by: John Chan | last post by:
Hi, Im doing a maintenance application in ajax and coldfusion at work on IE6 exclusively. I have a save button on each form and i have to do various validations server side and on client side when the user clicks save i.e check that user exists in table, check users password is the same as password in table, check password is valid, check that logged in user is a super user etc etc to get the correct error message. Different forms may or...
5
2727
by: Steve Wright | last post by:
I have an AJAX routine on a webpage that is working in IE6, but not IE7 or Firefox v2.0.0.2 The webpage is http://www.a-drop-in-the-ocean.co.uk/CWS/monitor10bins.php?quarry=401 The AJAX routine is encapsulated in the module http://www.a-drop-in-the-ocean.co.uk/CWS/js/timer.js
2
3812
by: Mike P | last post by:
Whenever I startup an Ajax Control Toolkit Website I get the following error: Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. C:\Inetpub\wwwroot\LBM_CallRecordings2\web.config 31 Can anybody help? Any assistance would be much appreciated.
8
1711
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I'm about to finally make the jump and start a new site using AJAX. THe question i have for all of you AJAX developers out there is which one? 1. The Standard AJAX frame work 2. The Tool kit. 3. Or are there others out there. 4. Should i not do AJAX at all because it still posts back the entire page even though only the section is refreshed. (someone tell me i'm wrong here and why please!)
21
29821
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays prodcut anme have used ajax to avoid refreshing of page this works fine 2.now i have created one row with checkbox|select box|text|text|text|text| where in the select box values are fetched from table here also i have used ajax for getting the m_name...
6
1710
by: =?Utf-8?B?UmJydA==?= | last post by:
I am trying to figure out how to do a postback that updates only changed controls without having the entire page refresh and flash on the screen. Seems to me this was available in ASP.NET 1.1, but I can't remember how it was done (I did it in another project but can't remember how). I do not want to use Ajax. I tried a search but got so many hits related to Ajax that I gave up. Thanks
3
2136
by: dmorand | last post by:
I have a page where I'm using ajax to retrieve some employee info when a user clicks a "Retrieve Employee Info" button. The issue I'm having is that when the user updates the employee info, saves the data, then hits the retrieve employee info button again the data being retrieved is the original data, not the updated data. This only occurs in any IE browser, firefox works fine. In firefox everytime I hit the retrieve employee info button,...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.