How do I prevent XML download from caching?

Get help using Construct 2

Post » Wed Jan 28, 2015 9:27 am

Hi,

I'm not yet sure if that is the problem but it seems like it. My app relies heavily on downloading an xml file from a server on startup via AJAX + the XML object. The file needs to be the most recent version. Think RSS reader (it's not, but the requirement for the most recent file is the same).

It works nice but when I modify the xml file on my server it often doesn't appear to affect the data received by my game. So the most likely explanation is that my game is caching the file and not downloading it every time.

Is it supposed to work like this? Is it preventable?
B
16
S
7
G
1
Posts: 167
Reputation: 3,143

Post » Wed Jan 28, 2015 1:01 pm

Your server is probably sending HTTP headers that indicate the browser can cache the response.

A simple workaround is to append a random number to the end of the request, e.g. request "file.xml?" + random(100000). But it's better if you can configure the server to not cache the file.
Scirra Founder
B
402
S
238
G
89
Posts: 24,637
Reputation: 196,071

Post » Wed Jan 28, 2015 5:47 pm

Thank you Ashley, the workaround works very well. Now I will have a look at how to configure the server not to send these headers in the first place.
B
16
S
7
G
1
Posts: 167
Reputation: 3,143


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Yahoo [Bot] and 8 guests