title: How to dynamically serve manifest for GWT permutations
body: <p>Consider the following problem. You'd like to serve an offline manifest/appcache file for your GWT project. In such a case, there are two issues:</p>
  
  <ol>
  <li>GWT generates different permutations of js files (depending on browser version). When loading the application, some GWT javascript code uses your user-agent properties to include the appropriate one. You'll want to generate a different manifest file for each of these permutations, as you don't want to cache files you won't use (and these files can be around 0.5MB per permutation). This issue is covered by the <a href="https://code.google.com/p/mgwt/wiki/HTML5Manifest" rel="nofollow noreferrer" title="MGWT Manifest Linker">MGWT Manifest Linker</a>, which generates different manifest files during the compilation process</li>
  <li>Serving the appropriate manifest file when loading the webapp in your browser</li>
  </ol>
  
  <p>This question relates to issue 2. How can we serve this manifest dynamically, in a robust way? MGWT uses a <a href="https://github.com/dankurka/mgwt/blob/master/src/main/java/com/googlecode/mgwt/linker/server/Html5ManifestServletBase.java" rel="nofollow noreferrer" title="Html5ManifestServletBase">servlet</a> which serves the manifest, depending on the user agent from the request. 
  You would need to map your user agent string (e.g. <code>Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.1)</code>) to a 'user-agent id' (e.g. <code>ie6</code>). Using a mapping file created by the MGWT linker, you can find the manifest file to serve to the client. A major downside is that you'll need to do some simple string operations to map the complete user agent string to this user agent id with some naive string matching. You won't be able to re-use the client-side GWT code for such a mapping. (this is all discussed in <a href="https://stackoverflow.com/questions/18696716/detecting-gwt-permutation-on-server-based-on-user-agent" title="Detecting GWT permutation on server based on user agent">this topic</a>). As a result, whenever GWT receives an update which changes the number of permutations, and/or the supported browsers, you'll need to change your servlet code as well. In other words: this is not a robust solution.</p>
  
  <p>The question is: can we serve the manifest in a different way for these GWT permutations, by serving these file dynamically on the client side?</p>