Preventing JS or CSS Caching on Web Applications

It is very important for dynamic web applications, any js and css changes to become available to user (without need to refresh – reload browser page).

Instead of

<script type="text/javascript" src="index.js"></script>

use:

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

Everytime you modify JS file, use next version num (actually, you can use any other string, but ?version=n is more nice). So, you force user browser to retreive JS in case it is changed.

The same method can be applied for CSS.