Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vaadin @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).

like image 852
herman Avatar asked Jan 12 '15 17:01

herman


2 Answers

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.

like image 164
David Blaney Avatar answered Sep 28 '22 09:09

David Blaney


This is browser feature to localy cache JS files, nothing to do with Vaadin.

As you figure it out yourself: If you want to make sure users have latest version of JS file, you should rename JS file name to: script_buildNumber.js.

like image 28
Zigac Avatar answered Sep 28 '22 08:09

Zigac