Since you are sending the previous modification time in every Ajax request but the first, why not have the PHP code echo the message, then die()?
If changes are missed, you could put the sleep() call in the code that writes the file content rather than in your loop.
Since you are sending the previous modification time in every Ajax request but the first, why not have the PHP code echo the message, then die()?
If changes are missed, you could put the sleep() call in the code that writes the file content rather than in your loop.