javascriptvaadin

Vaadin 8 @Javascript : clear cache for updated JS file


I have a @JavaScript annotation in my application to load a .js file from the classpath.

Now I've made an update to the file and redeployed (locally), but I always get the old version back. I've tried reloading everything (ctrl+R, ctrl+F5) but that doesn't work and also I wouldn't want the users to have to do that.

A trick I used in the past (without Vaadin) was to append a request parameter with the version (e.g. ?version=1) and update that so that the URL changes. But apparently that isn't allowed for the @JavaScript annotation (Vaadin doesn't even try to load the file).


Solution

  • I have overcome this by utilizing the resourceCacheTime parameter of the Vaadin servlet configuration:

    @VaadinServletConfiguration(ui = MyUI.class, resourceCacheTime = 0)
    

    Although it has its limitation as described in my answer to another question here.