title: Grails: best way to send cache headers with every ajax call
body: <p>It's well known that <a href="http://thinking-in-code.blogspot.com/2010/06/preventing-internet-explorer-from.html" rel="noreferrer">Internet Explorer aggressively caches ajax calls</a> whereas all the other browsers grab the data fresh every time.  This is usually bad:  I've never encountered a case where I want ajax to NOT contact the server.  Firefox, Safari and the other browsers know this and don't cache ajax calls.</p>
  
  <p>To prevent IE from caching, you have to do one of the following:</p>
  
  <ul>
  <li>add a cache-busting token to the query string (like <code>?time=[timestamp]</code>)</li>
  <li>send a HTTP response header that specifically forbids IE to cache the request</li>
  <li>use an ajax POST instead of a GET</li>
  </ul>
  
  <p>I much prefer setting a no-cache header.  It's the correct way:  it tells all browsers not to cache, which is exactly what you intend.  The query string method fills up the browser's cache with stuff that'll never be retrieved, leaving less room for legitimate cache content.  And the POST method is a corruption of HTTP:  POSTs are for modifying data.</p>
  
  <p>In Grails, what's the best way to automatically send a do-not-cache header for all ajax requests?  I don't want to modify any controllers, so I'm thinking there's got to be a cool filter trick or something.</p>
  
  <p>Thanks!</p>