Alex Rivera | Logout

Stop browser scripts caching in GWT App

Asked 2010-08-04T16:30:43.527
15

I have a GWT app deployed onto our client's machines. As an ongoing development alongside, we have to release new improved versions of the application fron time to time. Everytime we release a new version we often run into the problem where the client's browser has cached the old scripts scriptsand for a while it behaves strangly as the data it is trying to work with is not quite compatible with it. What is the best way to overcome this problem. Currently I have to tell the users to clear their browser's cache for a new release but it would be nice they don't have to do this.

Edit
Report

1 Answer

14

By default, the bulk of your app should be cached by the browser until a new version of it is generated by your build process.

It might help to understand the GWT bootstrapping model to understand how this works.

The first script your client requests, your-app-name.nocache.js, is not cached, and it does nothing except check the browser's user agent and capabilities, and make a second request for the relevant app JS.

At this point, the script it requests should be cached by the browser if it's been requested before. This is a {indistinguisable-numbers-and-letters}.cache.html file.

When you redeploy your app, the nocache.js file will be executed and ask for a different cache.html file from the server, which will not already be present in the cache, but which will get cached by the browser once it is downloaded.

Are you doing anything unusual with deferred binding, or with caching headers on your server? This might potentially be causing your nocache.js file to get cached after all, which would make it request old cache.htmls from the browser cache.

answered 2010-08-04T19:47:23.370

Your Answer