I have a use case where my GWT application is running on a client browser and I stop my tomcat and update the relevant WAR.
What I’d like to happen is that once I load the tomcat every existing client will be reloaded automatically so they will be using the correct version of the application.
Currently I’m facing two problems:
- I don’t know how to signal to the currently loaded application that it’s obsolete and it should reload. I’m thinking of somehow identifying in my app that the reason for the GWT-RPC failure is 404 and so it should reload, but I’m not sure how this could be identified. I cannot reload on every GWT-RPC of course as the server might just be down for no reason and will be back up in a second or two without a problem.
- For some reason, the moduleName.nocache.js file is cached and so even if I manually refresh I can see a 404 request on the server as the app is looking for a non existent resource (the previous version), once I delete the cache of the browser this is resolved. Does anyone have any ideas why this is cached? I have changed nothing, in this regard, to the server settings.
Edit:
1. It seems there is no GWT straightforward way of doing this so what I’ve decided is that when a module loads it receives a module version, a Double, and if a GWT-RPC fails the module queries the Server for its current module version and if there is a mismatch it reloads the page. The GWT-RPC which is used to query the module version is constant and won’t be changed for compatibility reasons. This way, even if all other GWT-RPC methods change the module is guaranteed this method will be valid.
2. It seems, thanks to BalusC’s suggestion, that the file is cached for 5-10 minutes only and that’s why I’ve been seeing non-deterministic behavior in this area. I’ve opened another question on how to set the headers on a single js file as I read somewhere that it’s related to the container and not to GWT.
Thanks,
Ittai
HTTP doesn’t support pushing of data. You need to use a webserver specific technique. In Tomcat, that’s Comet. This is however a lot of work. I would rather recommend to use JavaScript/Ajax to let the client poll for the version change at certain intervals. E.g. every five minutes or so. If the result indicates a change in the version. then you can let JavaScript reload the page by
window.location.reload.As to your caching problem, verify the response headers of the requested file in question. It should match at least the following headers: