So my all my web-pages include CSS and Javascript files.
E.g:
<script src="/scripts/example.js"></script> <link rel="stylesheet" type="text/css" href="/css/example.css">
Now I want to make a caching policy to make my website load faster. The problem with caching is that when your Javascript and CSS files are cached for a user, and you update one of those files, the user does not receive the update because the browser serves the cached version. Resulting in breaking the website for that user in the worst case.
So I wanted to solve this by making a kind of version control. If I would simply rename my files from "<script src="/scripts/example_1.js"></script>" to "<script src="/scripts/example_2.js"></script>" every time I edited example.js, the problem would be solved.
First I wanted to automate this by doing something like "<script src="/scripts/example_$TIMESTAMP$_.js"></script>", or $COTENT_HASH$,... But that seemed a bit overkill.
The solution I am currently considering is just adding ?v=VERSION_NUMBER to the files. Like this:
<script src="/scripts/example.js?v=1.0.0"></script> <link rel="stylesheet" type="text/css" href="/css/example.css?v=1.0.0">
I'd edit the updated versions manually in my source code. Is this a good solution? How do you guys do it? In some (old) articles I read that not all browsers cache files containing a '?'. Is that true?
Thanks!

New Topic/Question
Reply



MultiQuote



|