You can use a logic combination of PHP and Javascript (more specifically JQuery) with a trick. Of course this is a work-around approach (can be modified to make it better).
Pseudo-example can be like:
// A new PHP file "proxy.php"
<?php
if (!empty($_GET) && !empty($_GET['check'])) {
$previouslyChecked = $_GET['check'];
if (filemtime("filename.txt") > $previouslyChecked) {
echo 1;
} else {
echo 0;
}
die();
}
// Your PHP File
<html>
<head>
<script type="text/javascript" src="jquery.min.js"></script>
</head>
<body>
<?php
include('filename.txt');
$lastModified = filemtime("filename.txt");
?>
<input type="hidden" id="loadedAt" value="<?php echo $lastModified; ?>"/>
<script type="text/javascript">
function reloadPage(){
console.log("within reload");
window.location.reload();
}
function checkFile(){
console.log("checkfile");
jQuery.ajax({
type: "GET",
url: "proxy.php",
data: {check: jQuery("#loadedAt").val()},
success: function(data){
if (data == 1) {
console.log("reload called");
reloadPage();
}
setTimeout(checkFile, 5000);
}
});
};
jQuery(document).ready(function(){
console.log("checkfile called");
checkFile();
});
</script>
</body>
</html>
Hope this may work.