How to update an XML file without reloading the page

0

Good afternoon, I'm creating an application that loads functions based on information from a given XML file. However, as soon as I save a new function via php, when I make an XHttpRequest in javascript the code remains the same. I've already tried using the requestHeader ("cache-control", "no-cache") but I'm still having problems. Does anyone know a solution to my problem? I am using cache-control unduly? Any help is appreciated

EDIT: Resolved according to the answer, I discovered what I was doing wrong.

    
asked by anonymous 04.03.2017 / 13:58

1 answer

0

Cache-control can not be used in requests, only in responses, you can create a php file that returns your xml file every time it is called. See the code below:

$xmlfile = file_get_contents ( "myfile.xml" );
header ( "Cache-Control: no-cache" );
header ( "Pragma: no-cache" );
header ( "Content-type: text/xml" );
echo $xmlfile;

In this way you can return the file and every time a new request is made, no cache will be used.

    
04.03.2017 / 17:08