CACHE MANIFEST does not update files

0

Good afternoon, I'm creating a website that should work offline. my idea is that when the user has internet connection the pages of the site should be downloaded to the browser cache, and when the user is offline the pages should be retrieved from the cache, until this part I was able to do using CACHE MANIFEST but even Being online when I change my files continues to always fetch from the cache, forcing the user to clear the cache to get the new changes. Does anyone have any idea how I can do to "clear the cache" only if there is any change between files?

    
asked by anonymous 09.02.2018 / 16:31

1 answer

0

I have read some of the CACHE MANIFEST documentation and it seems to have many possible configurations. But the most accurate way I know is to handle the conditions if you create a script like this within the HTML header you can check if the page is online:

if(navigator.onLine == true){
    //tem conexao

}

But if I'm going to do something I'd advise using PHP:

<?php
$nc = "?".date("Ymdhis"); //exemplo 201802100720
?>
<html>
<head>
<script src="javascript.js<?php echo $nc; ?>">
</head>
<body>
<img src="imagem.jpg<?php echo $nc; ?>" />
    
10.02.2018 / 11:02