File versioning system

Asked

Viewed 38 times

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?

  • 1

    That part of "Blocks" is iframes?

  • @Sam yes they are iframes

  • You say it doesn’t work. What doesn’t work? It doesn’t update the cache or load the pages in iframe?

  • @Sam and manage to solve the part of iframes, but I want a more practical way to update html files, css, js...

  • 1

    In my view the most practical way is what is doing, generating a random number and adding in the path of the files.

  • ah ok, thanks for the attention

Show 1 more comment
No answers

Browser other questions tagged

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