I have a question. In old project that I'm currently working on I have found this code:
David R's answer is pretty good, but I want to add a little bit info:
Usually there are two approaches for cache-breaking:
The first approach may be better for some cases (see this question), but can be more painful. How would you keep this file in version control? What if there are many files like this?
The second approach is much easier. You just add something like
<some_string> can be whatever: timestamp, build number or just a random string.
For this approach, you may find it better to use automatic tools like gulp-rev.
Update: Honestly, it would be much better to have a revision number for all statics in the project: html, images, css, js. There a lot of tools to make this automatic.
Alternatively, there are some technics, for example angular developers have the
$templateCache service which allows the developer to put all the project's html (excluding index.html) in a single js file.