Recently I discovered a problem relating to caching in my GWT app when running on iOS 6.x devices in web-app (fullscreen) mode. The problem is that iOS seems to ignore my cache policy directives on the bulky permutation files (<hash>.cache.html
.)
I have a servlet filter setting cache headers on static resources including *.cache.html
files, e.g.:
# Response header snippet
Expires: Fri, 26 Jul 2013 09:58:28 GMT
Cache-Control: public, max-age=8640000
ETag: W/"322107-1359629388000"
Last-Modified: Thu, 31 Jan 2013 10:49:48 GMT
However, as soon as I put in web-app support and add the app to my home screen the iOS device will request the permutation file on every load and sends neither If-None-Match
nor If-Modified-Since
request headers. Web-app support is added via a <meta>
tag:
<meta name="apple-mobile-web-app-capable" content="yes" />
I haven't been able to find this issue documented anywhere and am not certain it is a bug. It is, however, what I have experienced. Caching works as expected in my desktop browser where I can inspect the received headers. Nowhere do I sniff the user agent and distinguish based on this information so all clients will receive the same headers.
I was able to "solve" the immediate problem via an HTML5 cache manifest file as presented in this Google I/O talk: "Google I/O 2010 - GWT Linkers target HTML5 WebWorkers & more" where a custom GWT Linker generates a manifest file containing all generated permutations, e.g.:
CACHE MANIFEST
<hash1>.cache.html
<hash2>.cache.html
...
<hashN>.cache.html
And adds the manifest directly in the host page (<module>.html
):
<!doctype html>
<html manifest="[module-path]/offline.manifest">
...
This is all well except that all clients will now have to load all permutations eventhough only one is needed! I my case 18 permutations each ~5MB over 3G or Edge :( Is this really the best solution?