Redirect xml file update from server to all client browsers?

I am wondering if it is possible to transfer the xml file update from the server to all client browsers? Basically, my proposed situation is that my server stores an xml file, when the user loads a page using the specified XML file, which they can request to change it if the change is allowed (determined by the client side of the page), then the xml file is updated server side. I'm fine up to this point (well, I have a lot of reading to bring me to this point). Then I want all the pages that are connected to refresh all the page elements that depend on the xml file, without refreshing the whole page.
In other words, all these pages use the file to update their copy-> data if the copy on the server is newer than theirs. Is this possible by clicking on the server, or do I need to constantly poll the server to compare files? (This seems sloppy for me ..) And if it is possible, what is the best way to do this?

Thanks for any points in the right direction.

+3
source share
2 answers

- , . . ajax script, 5 , , script -, . ajax; jQuery , .

+3

AJAX php script, :

set_time_limit(3600); // one hour or set it as long as your session timeout is
// Keep on repeating this to prevent PHP from stopping the script
while (true)
{
  sleep(5); //5 seconds between polling the server
  //do the updates xml updates
  flush();
  ob_flush();
}

5 xml .

, , , APC, memcache , XML.

if(apc_fetch('xml_updated') == 1)
{
    //do the xml pull
}

, , . -, .

, !

0

All Articles