1

I get xml file from server with function ( JQuery )

function load_config_xml(){
    $.ajax({
        url: 'config/conf.xml',
        dataType: "xml",
        success:parse_xml,
        error: function(){
            alert("Error during loading xml file");
        }
    });
}

but it doesn't return fresh results, lighttpd caches. How to change request to avoid cached results ?

Danka
  • 291
  • 3
  • 7
  • 10
  • 1
    possible duplicate of [Stop jQuery .load response from being cached](http://stackoverflow.com/questions/168963/stop-jquery-load-response-from-being-cached) – redsquare Jun 28 '11 at 07:45

1 Answers1

1

Simplest workaround is to explicitly use a POST request. A browser will not cache those:

function load_config_xml(){
    $.ajax({
        url: 'config/conf.xml',
        dataType: "xml",
        type: 'POST',     // here we go
        success:parse_xml,
        error: function(){
            alert("Error during loading xml file");
        }
    });
}

jQuery also offers the option cache which you can set to false. That creates the some outcome:

cache: false

Basically jQuery will just modify the query string for each request, which of course you could do on your own aswell:

url: 'config/conf.xml?cachebuster=' + (+new Date())
jAndy
  • 231,737
  • 57
  • 305
  • 359