- Most web servers will serve up a static file no matter what query string you put at the end of the URL.
- Browsers cache data based on its URL.
- Changing the URL to a different one means you won't get the cached version from the old URL but, given (1), the (new version of the) file stored in the same location on the server's disk will be served.
But how does this help? How the query string going to work? I don't have the file name changed nor did I wrote any script for doing anything with query string (?v=1) .
Then it doesn't help. You have to change the query string when you change the file.
What am I missing? Do I need to change the file name
No
or do I need to have a repository for sure to get this working?
You need to change the query string when you release a new version of the file.
One way to do that would be to use a build script that sets the URL to (for example) the commit id that last changed the file in a version control repository.