CACHE MANIFEST does not update files

Asked

Viewed 69 times

0

Good afternoon, I’m creating a website that should work offline. my idea is that when the user has internet connection the site pages 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 keeps searching the cache, forcing the user to clear the cache to get the new changes. Does anyone have any idea how to "clear the cache" only if there are any changes between the files?

  • a simple solution is to save the file editado parameter arquivo.ext?n=atualizacao_numero_xxx where xxx = different number at each update

1 answer

0


I read part of the CACHE MANIFEST documentation and it seems to have many possible settings. But the most precise way I know is by manipulating conditions if you create a script like this inside the HTML header you can check if the page is online:

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

}

But if to do something precise I 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; ?>" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.