How to prevent caching of my Javascript file?

Scenario:

Since version 10 of Dynamic Web TWAIN, we introduced an HTML5 Edition to support the modern browsers on Windows.

The TWAIN HTML5 SDK is specifically addressing the phasing out of NPAPI plugins used by the browsers. For more information about the HTML5 SDK, please click here.

Now that we have JS Client, sometimes, a change is made on the server-side JS, but it doesn't get applied on the client-side because of caching.

Solution:

You can simply use Ctrl + F5 refresh to ensure the browser to get the up-to-date files from the sever, but you may not want to do it everytime.

A common solution is to add a ?<version> to the script src link.

For instance:

<script type="text/javascript" src="test.js?version=1"></script>

When you change the Sever side JS, you can change the version number.

Or if you are using a server side language, you could automatically generate this:

ASP.NET

<script src="test.js?rndstr=<%= getRandomStr() %>"></script>