This is how we prevent caching of JS and CSS files by browsers. This seems slightly hacky.. is there a better way?
<%
//JSP code
long ts = (new Date()).getTime(); //Used to prevent JS/CSS caching
%>
<link rel="stylesheet" type="text/css" media="screen" href="/css/management.css?<%=ts %>" />
<script type="text/javascript" src="/js/pm.init.js?<%=ts %>"></script>
<script type="text/javascript" src="/js/pm.util.func.js?<%=ts %>"></script>
Update: The reason we want to prevent caching is to ensure the newer version of the files are loaded when we do a new release.
You want CSS and JS to be cached. It speeds up the loading of the web page when they come back. Adding a timestamp, your user’s will be forced to download it time and time again.
If you want to make sure they always have a new version, than have your build system add a build number to the end of the file instead of a timestamp.
If you have issues with it just in dev, make sure to set up your browsers to not cache files or set headers on your dev pages to not cache.