I believe appending a version number to a JS file allows me to change that version number to guarantee a user isn’t viewing an old, cached version of the file.
But what is best?
Obviously (2) needs the filename changing, but looking at it, does (1) work? I’m 100% that (2) would work.
Are there any other downfalls of either of the methods? What do other people use?
I need to be 100% certain that changing the version number will ensure nobody gets an old file.
Both would work. Both would achieve the same thing. Pick the one you like best.
This is a handy way to automate it:
Another commonly used way now is to use a build system, so that all of your related files are packaged up in to just the one file.
For example, RequireJS has an optimizer that combines and minifies them in to just the one file, which can have its time/date in the filename.