title: How to make browser stop caching GWT nocache.js
body: <p>I'm developing a web app using GWT and am seeing a crazy problem with caching of the <code>app.nocache.js</code> file in the browser even though the web server sent a new copy of the file!</p>
  
  <p>I am using Eclipse to compile the app, which works in dev mode.  To test production mode, I have a virtual machine (Oracle VirtualBox) with a Ubuntu guest OS running on my host machine (Windows 7).  I'm running lighttpd web server in the VM.  The VM is sharing my project's war directory, and the web server is serving this dir.</p>
  
  <p>I'm using Chrome as the browser, but the same thing happens in Firefox.</p>
  
  <p>Here's the scenario:</p>
  
  <ul>
  <li>The web page for the app is blank. Accorind to Chrome's "Inspect Element" tool, it's because it is trying fetch <code>6E89D5C912DD8F3F806083C8AA626B83.cache.html</code>, which doesn't exist (<code>404 not found</code>).</li>
  <li>I check the war directory, and sure enough, that file doesn't exist.</li>
  <li>The <code>app.nocache.js</code> on the browser <strong>WAS RELOADED</strong> from the web server (200 OK), because the file on the server was newer than the browser cache.  I verified that file size and timestamp for the new file returned by the server were correct.  (This is info Chrome reports about the server's HTTP response)</li>
  <li><p>However, if I open the <code>app.nocache.js</code> on the browser, the javascript is referring to <code>6E89D5C912DD8F3F806083C8AA626B83.cache.html</code>!!!  That is, even though the web server sent a new <code>app.nocache.js</code>, the browser seems to have ignored that and kept using its cached copy!</p></li>
  <li><p>Goto Google->GWT Compile in Eclipse. Recompile the whole thing.</p></li>
  <li>Verify in the war directory that the <code>app.nocache.js</code> was overwritten and has a new timestamp.</li>
  <li>Reload the page from Chrome and verify once again that the server sent a 200 OK response to the <code>app.nocache.js</code>.</li>
  <li>The browser once again tries to load <code>6E89D5C912DD8F3F806083C8AA626B83.cache.html</code> and fails.  The browser is still using the old cached copy of <code>app.nocache.js</code>.</li>
  <li>Made absolutely certain in the war directory that nothing is referring to <code>6E89D5C912DD8F3F806083C8AA626B83.cache.html</code> (via find and grep)</li>
  </ul>
  
  <p>What is going wrong?  Why is the browser caching this <code>nocache.js</code> file even when the server is sending it a new copy?</p>
  
  <hr>
  
  <p>Here is a copy of the HTTP request/response headers when clicking reload in the browser.  In this trace, the server content hasn't been recompiled since the last GET (but note that the cached version of nocache.js is still wrong!):</p>
  
  <pre><code>Request URL:http://192.168.2.4/xbts_ui/xbts_ui.nocache.js
  Request Method:GET
  Status Code:304 Not Modified
  Request Headersview source
  Accept:*/*
  Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
  Accept-Encoding:gzip,deflate,sdch
  Accept-Language:en-US,en;q=0.8
  Cache-Control:max-age=0
  Connection:keep-alive
  Host:192.168.2.4
  If-Modified-Since:Thu, 25 Oct 2012 17:55:26 GMT
  If-None-Match:"2881105249"
  Referer:http://192.168.2.4/XBTS_ui.html
  User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4
  Response Headersview source
  Accept-Ranges:bytes
  Content-Type:text/javascript
  Date:Thu, 25 Oct 2012 20:27:55 GMT
  ETag:"2881105249"
  Last-Modified:Thu, 25 Oct 2012 17:55:26 GMT
  Server:lighttpd/1.4.31
  </code></pre>