Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Caching or what? 1

Status
Not open for further replies.

tsdragon

Programmer
Dec 18, 2000
5,133
US
I've got the strangest XMLHTTPRequest problem, and it occurs in both IE6 and FF3! I'm sending an XMLHTTP POST request to the server to update some data. The problem is that the response I'm getting back appears to be a cached response, sort of (I'll explain that in a minute). I've tried every method I could think of to prevent caching responses (using POST, cache control headers, content expiration headers, etc.) but nothing works. Even clearing the temporary files cache in IE6 doesn't work. The only thing that appears to work is closing the browser. Then I'll get ONE current response, but the problem starts all over again.

The symptoms are strange too, it's not like the 2nd and subsequent requests aren't sent to the server, they are, and I actually get responses back, just not when they should (they show up later). In order to try to diagnose the problem, I inserted the current time into both the request and the server response. Here is a list of the responses I got back on repeated requests. Sorry it's so long, but it's necessary to see the pattern. I've also numbered the lines and color-coded the first few to make things easier to follow:

1 [highlight #FB8985]47:10[/highlight] (this one is right on time)
2 [highlight #FB8985]47:10[/highlight]
3 [highlight #FBD085]47:19[/highlight]
4 [highlight #FB8985]47:10[/highlight]
5 [highlight #EAFA86]47:26[/highlight]
6 [highlight #FBD085]47:19[/highlight]
7 [highlight #A4FB85]47:34[/highlight]
8 [highlight #FB8985]47:10[/highlight]
9 [highlight #85FBCE]47:42[/highlight]
10 [highlight #EAFA86]47:26[/highlight]
11 [highlight #85D0FB]47:49[/highlight]
12 [highlight #FBD085]47:19[/highlight]
13 [highlight #858DFB]47:57[/highlight]
14 [highlight #A4FB85]47:34[/highlight]
15 [highlight #ffffff]48:05[/highlight]
16 [highlight #FB8985]47:10[/highlight]
17 [highlight #ffffff]48:12[/highlight]
18 [highlight #85FBCE]47:42[/highlight]
19 [highlight #ffffff]48:21[/highlight]
20 [highlight #EAFA86]47:26[/highlight]
21 [highlight #ffffff]48:28[/highlight]
22 [highlight #85D0FB]47:49[/highlight]
23 [highlight #ffffff]48:36[/highlight]
24 [highlight #FBD085]47:19[/highlight]
25 [highlight #ffffff]48:43[/highlight]
26 [highlight #858DFB]47:57[/highlight]
27 [highlight #ffffff]48:52[/highlight]
28 [highlight #A4FB85]47:34[/highlight]
29 [highlight #ffffff]48:59[/highlight]
30 [highlight #ffffff]48:05[/highlight]
31 [highlight #ffffff]49:10[/highlight]
32 [highlight #FB8985]47:10[/highlight]
33 [highlight #ffffff]49:17[/highlight]
34 [highlight #ffffff]48:12[/highlight]
35 [highlight #ffffff]49:25[/highlight]
36 [highlight #85FBCE]47:42[/highlight]
37 [highlight #ffffff]49:33[/highlight]
38 [highlight #ffffff]48:21[/highlight]
39 [highlight #ffffff]49:41[/highlight]
40 [highlight #EAFA86]47:26[/highlight]
41 [highlight #ffffff]49:51[/highlight]
42 [highlight #ffffff]48:28[/highlight]
43 [highlight #ffffff]49:59[/highlight]
44 [highlight #85D0FB]47:49[/highlight]
45 [highlight #ffffff]50:08[/highlight]
46 [highlight #ffffff]48:36[/highlight]
47 [highlight #ffffff]50:16[/highlight]
48 [highlight #FBD085]47:19[/highlight]
49 [highlight #ffffff]50:25[/highlight]
50 [highlight #ffffff]48:43[/highlight]
51 [highlight #ffffff]50:35[/highlight]
52 [highlight #858DFB]47:57[/highlight]
53 [highlight #ffffff]50:43[/highlight]
54 [highlight #ffffff]48:52[/highlight]
55 [highlight #ffffff]50:52[/highlight]
56 [highlight #A4FB85]47:34[/highlight]
57 [highlight #ffffff]50:59[/highlight]
58 [highlight #ffffff]48:59[/highlight]
59 [highlight #ffffff]51:24[/highlight]
60 [highlight #ffffff]48:05[/highlight]
61 [highlight #ffffff]51:35[/highlight]
62 [highlight #ffffff]49:10[/highlight]
63 [highlight #ffffff]51:42[/highlight]
64 [highlight #FB8985]47:10[/highlight]
65 [highlight #ffffff]51:50[/highlight]
66 [highlight #ffffff]49:17[/highlight]
67 [highlight #ffffff]52:00[/highlight]
68 [highlight #ffffff]48:12[/highlight]
69 [highlight #ffffff]52:07[/highlight]
70 [highlight #ffffff]49:25[/highlight]
71 [highlight #ffffff]52:15[/highlight]
72 [highlight #85FBCE]47:42[/highlight]
73 [highlight #ffffff]52:23[/highlight] (got this one at 57:23!)
Notice that the first response was also the 2, 4th, 8th, 16th, 32nd and 64th. The "second" response showed as the 3rd, 6th, 12th, 24th and 48th. The "third" response showed as the 5th, 10th, 20th and 40th. This pattern repeats reliably. Also notice that every other response is one that has not been seen before.

So, what would give me this kind of a strange pattern in returning responses that should not be cached in the first place? Also, if it were actually a caching issue, shouldn't ALL the responses be the same? It looks like every request is actually getting sent to the server and received back again, but they're not being returned sequentially.

Any ideas would be GREATLY appreciated! This has been driving me nuts for two days now!

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
FYI:

The server-side is an IIS v6.0 server running VBScript .asp programs.

I've tried two or three different XMLHTTPRequest "wrappers", and I've tried both sync and async modes.

I enabled content expiration on the server, and set it to expire immediately.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Solved this one myself, and boy do I feel like a world-class IDIOT! [blush] [banghead] [curse] [hammer]

The pattern you see is what happens when you use document.getElementById on a div and there happens to be more than 1 div with the same id!

Every time I got the response back I was creating a new div to contain the information (each time using the same id) and then using document.getElementById(divname) to display the div. Instead of throwing an error, the browser would find ONE of the divs with that id and return it to me. Oddly, both browsers apparently use exactly the same logic to determine which one to return!

Now I check if the div exists and reuse it if it does. No more problem (except that I STILL feel like a total MORON)!

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top