PDA

View Full Version : Prevent XML files from being cached by browser


guvenck
08-17-2007, 12:37 PM
Hi,

I realized that my browser caches the xml files I am using in my project and loads them from cache. That is not good for me, especially when I experiment locally and need to edit XML file every minute :)

So, it should be possible to make the browser load the file itself each time the XML file is requested. How can I do this?

guvenck
08-17-2007, 12:50 PM
I found the cure:

The solution is to add a unique identifier while calling the file, at the end of the xml file.

In my case, the code is:


xmlDoc.load('../xmlfiles/'+xmlFile+'?uid='+new Date().getTime());


Hope it might help someone.

Alex Vincent
08-17-2007, 11:02 PM
There's probably a better solution through HTTP headers (pragma: no-cache?).

guvenck
08-20-2007, 03:31 PM
I read somewhere that Firefox still shows the older XML file, when a header cache solution like yours is used.