Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Setting cache time on a ThemeResource
My application is currently suffering at a result of icons set as Embedded object being reloaded instead of cached on the browser.
The Vaadin book give an example but this is loading in image from soem arbirtaty location (which would mean I have to use FileInputStream with exception handling), in my case I need to load the image file depending on which Theme is currently in use. The ThemeResource object does not have a method to set the caching time.
I expect this would be a problem on any other application using Theme Resources, why isn't there a way to set cache time on those, perhaps it isnt possible for some other reason?
Can somebody explain how any kind of Theme resouce cahing curretly occurrs or any suggested way to prevent ThemeResources from being reloaded by the browser?
Rick Smith: I expect this would be a problem on any other application using Theme Resources, why isn't there a way to set cache time on those, perhaps it isnt possible for some other reason?
I am having the same problem with my application. So is there anything we can do to fix this one? Anyone?
Rick Smith: Can somebody explain how any kind of Theme resouce cahing curretly occurrs or any suggested way to prevent ThemeResources from being reloaded by the browser?
The handling of static theme files depends on the server that serves them to the client. In a basic Vaadin environment, where all static content from WebContent/VAADIN folder is served through the Vaadin ApplicationServlet, no cache parameters are set. This is an obvious defect on our part, and we've been planning a fix for quite a while now. Should get fixed in 6.3. Here's the ticket: #2586.
Would the proposed "Cache-Control: must-revalidate" header cause troubles, or would those small HEAD-requests be sustainable in your environment?
But if you decide to serve these static resources from outside the Vaadin servlet and unpack the themes and widgetsets outside of the JAR, you have to make sure that the server that handles those resources attaches proper cache headers to them. I think most web servers do this by default. You can use this as a workaround until we fix our defect.
Unpacking the static resources from the JAR and serving them outside the servlet is suggested in final deployments, since it reduces traffic for the servlet quite a bit.
It seems I have the reverse problem. I am using 6.6.5 and I have changed some png files in my VAADIN/themes/foo theme. No matter what I do, the old images is displayed for my button. If I remove my browser cache, it works.
The theme files are served by the Vaadin servlet
How can I control when a image must be refreshed?