A very simple question, I need time when a file was cached on client's computer.
I want to reload page from server if it's modified after the time of cached file.
Is it possible? I'm completely unaware about this. Any help will be appreciated.
A very simple question, I need time when a file was cached on client's computer.
I want to reload page from server if it's modified after the time of cached file.
Is it possible? I'm completely unaware about this. Any help will be appreciated.
You could embed a timestamp into the html somewhere:
<body data-generated="<?php echo time();?>">
Then check this against server updated time, via an ajax request:
//jquery for berevity
$.get('invalidate_client_cache.php?time='+ $('body').data('generated'), function(data){
if(data.invalidate){
location.reload(true);
}
}
I will leave the php implenentation to you, as i dont know yout requirements, but it could be something like:
$clientCacheTime = isset($_GET['time'])? $_GET['time'] : null;
$data=[];
$data['invalidate'] = reloadRequired($clientCacheTime);
header('Content-Type: application/json');
echo json_encode($data);