How do I prevent XML download from caching?

0 favourites
  • 3 posts
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)