Skip to content

Instantly share code, notes, and snippets.

@thulioph
Created December 6, 2013 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thulioph/7830929 to your computer and use it in GitHub Desktop.
Save thulioph/7830929 to your computer and use it in GitHub Desktop.
cache.js
var appCache = window.applicationCache;
// Verifica se um novo cache está disponível no carregamento da página.
window.addEventListener('load', function(e) {
window.applicationCache.addEventListener('updateready', function(e) {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
// O Browser baixa o novo cache
// Troque o cache e recarregue a página para obter o novo conteúdo
window.applicationCache.swapCache();
if (confirm('Uma nova versão do site está disponível. Recarregue a página!')) {
window.location.reload();
}
} else {
// O manifesto não mudou, não existe nada de novo.
}
}, false);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment