Vaadin @Javascript:清除更新的JS文件的缓存 [英] Vaadin @Javascript : clear cache for updated JS file

查看:96
本文介绍了Vaadin @Javascript:清除更新的JS文件的缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个@JavaScript注释,用于从类路径加载.js文件。

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

现在我对文件进行了更新并重新部署(本地),但我总是得到旧版本。我已经尝试重新加载所有内容(ctrl + R,ctrl + F5),但这不起作用,我也不希望用户必须这样做。

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.

我过去使用的一个技巧(没有Vaadin)是附加一个带有版本的请求参数(例如?version = 1)并更新它以便URL发生变化。但显然@FavaScript注释不允许这样做(Vaadin甚至不尝试加载文件)。

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

推荐答案

我已经通过使用Vaadin servlet配置的 resourceCacheTime 参数克服了这个问题:

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.

这篇关于Vaadin @Javascript:清除更新的JS文件的缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆