FileResource not getting released?

Hi guys

I am using the the FileResource() class for the source of an Embedded image and I am running into a strange problem: the FileResource() does not seem to be clearing at all, and it does not matter if I restart the session or do a clean-build in NetBeans.

What I mean is this:

  1. I have a layout with a button, with a clicklistener attached to it, and everytime somebody clicks the button an image gets uploaded and displayed in a subwindow.

  2. I upload an image file (test.jpeg) to a new FileResource(), and then use it as the source for Embedded component.
    The image url, on an application server, is: " http://localhost:8080/MyApplication/APP/1/test1.jpeg

  3. Now, when I click on the button again (same file used for uploading, new FileResource()), another subwindow opens with an address: http://localhost:8080/MyApplication/APP/2/test1.jpeg
    I.e. the referenceId increases with every subsequent window.

  4. Now let’s say I redeploy the application to the server.
    If I type in “http://localhost:8080/MyApplication/APP/2/test1.jpeg” for example, the image will get displayed in the browser.

How can this happen? After redeployment, the button has not been pressed yet. How can the reference to the image already exist? For some reason it seems to be getting cached but how can this cache stay across redeployments? Even restarting the whole Netbeans IDE does not make a difference. The files are not getting stored in the server folder so does the application know what file to display? Shouldn’t the attached resources clear on application close?

Ok, the problem was with the browser cache.

The application was still refering to the same URI, but there was already something cached in that place so the browser was just reloading the old image.

setting setCacheTime(0) solved the problem => now the images are only stored for the duration of the session. This being said, I think it might be better to make the DEFAULT_CACHETIME = 0 as default, in the Vaadin ApplicationResource.class. Currently it is set to 24 hours, which made it a bit tough to identify the problem.