title: How to automate versioning of static files (css, js, image) in a Java web app
body: <p>I want to use the browser cache of static files most efficiently, i.e. always use cached content, unless the file has changed, in which case get the new content.</p>
  
  <p>I'd like to attach an md5 hash of the file to the virtual file path (either as a directory, or as part of the file name) the client sees, so that it when the file changes, the client thinks it is a different resource.</p>
  
  <p>I know how to use a servlet filter to take a request containing that virtual file path and strip the md5 hash, and return the real file name in the directory structure.</p>
  
  <p>Can I also use a filter to change the apparent file name on the way out, so that the client's browser thinks it is requesting the virtual file path, without changing the actual name or directory structure of my actual files?</p>
  
  <p>For example:</p>
  
  <p>real file path = /css/1.css</p>
  
  <p>virtual file path = /static/1234/css/1.css</p>
  
  <p>when the file changes</p>
  
  <p>real file path = /css/1.css</p>
  
  <p>virtual file path = /static/3451/css/1.css</p>