Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Cache images in browser
Hello all,
maybe someone has an idea. My application exists of a lot of small images (like a web shop), but unfortunately everytime the images reloaded again and will not be cached (I see this in the "Chrome developer tools").
I use a FileResource to display the image:
FileResource fr = new FileResource(file)
Image image = new Image();
image.setSource(fr);
layout.addComponent(image);
Has anyone an idea, why this happen?
Best Regards,
Thomas
I tested other types of resourcs, but unfortunately I have the same issue. Is there maybe a setting to say that a resource needs to be cached?
I suppose you don't have the Disable cache setting enabled in Chrome dev tools (which is on by default)?
Hello, I changed nothing in the configuration.
But maybe you have a try:
https://www.lunchlist.de:28443/?id=demo
Thanks,
Thomas
Hi,
if you haven't changed anything in the Chrome dev tools configuration, then you are disabling caching automatically when you open the Dev Tools panel. This is a built-in feature of the Dev Tools and you can toggle it off from the Network tab.
-Olli
Hello,
Thanks for the information, but the checkbox "disable cache" is not set, if I open the dev-tools.
What happens, if you open lunchlist. Are the images (after the login) cached?
Thanks!
Regards,
Thomas
Theme resources like fonts seem to come from cache in your application. Have you tried using a ThemeResource instead of a FileResource?
-Olli
Hello,
Do you have the same issue for images which are not coming from a ThemeResource?
The problem ist that some images are stored on the file system and therefore I have no possibility to load these images from the the theme folder? But of couse, I will test it.
Regards!
I tried to load some images via a ThemeResource, but still no difference in the dev-tools. But you are right, some files (fonts, spinner, etc.) are cached...
But I think this should also use the cache by loading with a FileResource. I checked the following page http://demo.vaadin.com/book-examples-vaadin7/book#application.resources.classresource and also see that caching does not work.
Regards,
Thomas
It seems that in general it is possible, because loading images from http://demo.vaadin.com/dashboard/#!schedule are coming from cache... Does anyone has a tip to go in the right way to fix this..? :)