0
Hello guys I made a simple code in Javascript to update the page cache
Follow the code:
//sistema de versionamento de arquivos
var number = Math.floor(Math.random() * 999999999 + 1000000) //gera um numero aleatorio entre 1000000 e 999999999
//css
document.getElementById("css").href = "css/browse.css?v=" + number;
//js
document.getElementById("js").src = "js/browse.js?v=" + number;
//blocks
document.getElementById("lastadded").src = "blocks/lastadded.html?v=" + number;
document.getElementById("movies").src = "blocks/movies.html?v=" + number;
document.getElementById("series").src = "blocks/series.html?v=" + number;
document.getElementById("animes").src = "blocks/animes.html?v=" + number;
I don’t know what’s going on, but the Blocks part doesn’t work. that code is inside js/Browse.js.
Does anyone explain what is wrong, or has a better way of dealing with this cache problem?
That part of "Blocks" is iframes?
– Sam
@Sam yes they are iframes
– Luiz Filipe
You say it doesn’t work. What doesn’t work? It doesn’t update the cache or load the pages in iframe?
– Sam
@Sam and manage to solve the part of iframes, but I want a more practical way to update html files, css, js...
– Luiz Filipe
In my view the most practical way is what is doing, generating a random number and adding in the path of the files.
– Sam
ah ok, thanks for the attention
– Luiz Filipe