Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Cache images in browser
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();
Has anyone an idea, why this happen?
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:
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.
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?
Theme resources like fonts seem to come from cache in your application. Have you tried using a ThemeResource instead of a FileResource?
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.
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.
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..? :)