Browser cache problem with images and PDFs

Hi,

my app is showing images through the ImageScaler add-on. The images are loaded from a database. This works in principal.

My problem is, that after some time I get wrong images displayed even though I read the right images from the database! I.e. if I switch between 2 images back and forth, I see sometimes wrong images (other than the 2 expected ones). This sounds very weird, but I can reduce the amount of wrong images by clearing the browser cache.
I had the same problem with PDF files generated via JasperReport: I saw sometimes reports from last week!

Some more details: I display the images and the pdf files in application level windows. Vaadin seems to store the generated files/images at an url like
app://APP/125/Image
. I can see this, when I start Firebug and look at the answer:

for(;;);[{"changes":[["change",{"format": "uidl","pid": "PID181"},["20",{"id": "PID181",
"height": "100.0%","width": "100.0%","image": "app:\/\/APP\/126\/Image",
"imageWidth":900,"imageHeight":1280}]]], "meta" : {}, "resources" : {}, "locales":[]}]

Now my question: how can I switch off the caching of such images/pdfs? Or is there something else I can do?

Regards

Andreas

The usual workaround of this problem is to add a random number, often a simple timestamp, to the name of the file. Thus, each file name is unique, and it tricks the browser into getting the new file, while when using the same name, it tries and re-use the file in the cache.
You can find an example of such usage in the
Book Example on drag’n’drop of components
, at the end of the source (the connectors are PNG generated on the fly).

Hi Philippe,

thank you for your comment. Now I get always the images I want :slight_smile:

What do the Vaadin guys think about this? Does it make sense to mark such resources as

transient

to avoid the browser cache getting polluted with them?

Best regards

Andreas

I think I have the same problem, but as I’ve examined it a bit, it looks like it’s not the browser cache where the problem is… or at least not the only one :slight_smile:

If you look at the public URL of images from Vaadin in browser, they are generated, it means Vaadin have to copy the image to some publicly visible place… to reduce the amount of images which have to be copied, it looks like he sometimes tries to look if he already copied image with that name and use already existing link instead of copying the image again on newly generated place. This results that sometimes it uses the link with old image. But only sometimes, so no idea what is the exact login behind it :smiley: