Tuesday, 10 September 2013

How to dynamically serve manifest for GWT permutations

How to dynamically serve manifest for GWT permutations

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:
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 MGWT Manifest Linker,
which generates different manifest files during the compilation process
Serving the appropriate manifest file when loading the webapp in your browser
This question relates to issue 2. How can we serve this manifest
dynamically, in a robust way? MGWT uses a servlet which serves the
manifest, depending on the user agent from the request. You would need to
map your user agent string (e.g. Mozilla/4.0 (compatible; MSIE 6.0b;
Windows NT 5.1)) to a 'user-agent id' (e.g. ie6). 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 this
topic). 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.
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?

No comments:

Post a Comment